#codefestivalchinad. [code_festival_china_d]Maze

[code_festival_china_d]Maze

Problem

There is a maze which has 11 start and 22 goals. The maze is made of HH rows and WW columns rectangular array of cells. Each cell is specified as start, goal, pathway, or an obstacle. Let (r,c)(r, c) be the rr-th row's, cc-th cell from the left.

You will be given a map of the maze. You have to draw two paths from start cell to each goal cell in that map. A path is an array of cells that begins with start cell and ends with goal cell, contains no obstacle cell, and each pair of neighboring cells in the array is adjoining. A pair of cells (a,b)(a, b) and (c,d)(c, d) is adjoining if ac+bd=1|a-c|+|b-d|=1. The paths you draw must fulfill the following conditions.

  • Each path must contain the least possible number of cells. That means each path must be the shortest path from start to each goal.
  • To make paths distinguishable, each path must not have any cell in common, except the start cell.

Determine if you can make the paths that meets the condition in the given maze, and show the paths in the maze if possible. Read the Input and Output section for the detailed format.


Input

HH WW s(1,1)s_{(1,1)}s(1,2)s_{(1,2)}s(1,W)s_{(1,W)} s(2,1)s_{(2,1)}s(2,2)s_{(2,2)}s(2,W)s_{(2,W)} : s(H,1)s_{(H,1)}s(H,2)s_{(H,2)}s(1,W)s_{(1,W)}

  • On the first line, two integers HH, WW (1leqH,Wleq501 \\leq H, W \\leq 50), the size of the maze is given.

  • On the following HH lines, each line containing a string of length WW, the map of the maze is given. The ii-th (1leqileqH1 \\leq i \\leq H) line's jj-th (1leqjleqW1 \\leq j \\leq W) character represents the cell (i,j)(i, j). Each character means as following.

    • . represents that the cell is a pathway cell.
    • # represents that the cell is an obstacle cell.
    • S represents that the cell is the start cell.
    • A represents that the cell is the first goal cell.
    • B represents that the cell is the second goal cell.

    It is guaranteed that the character S, A, B appears only once. Also it is guaranteed that for each goal there's at least 11 path.

Output

If there are no paths to fulfill the conditions in the problem section, output 11 line containing NA.

If there are paths that fulfill the conditions, Output HH lines that each line consists of WW characters. The ii-th (1leqileqH1 \\leq i \\leq H) line's jj-th (1leqjleqW1 \\leq j \\leq W) character in the output should represent the cell (i,j)(i, j) in the maze. The output must fulfill the following conditions.

  • The cell that was a pathway in the input must be one of ., a or b.
  • The cell that was a start, an obstacle, or a goal cell in the input must be the same character as in the input.
  • It should be able to reach the goal cell A from the start cell by following the adjoining a cell. The number of cell a must be the least possible to reach the goal.
  • It should be able to reach the goal cell B from the start cell by following the adjoining b cell. The number of cell b must be the least possible to reach the goal.

In other words, show the path to each goal A, B by the characters a, b. If there are more than one possible answers, you may choose any one of them.

Make sure to insert a line break at the end of the output.


Input Example 1


5 5
..#..
.B.A#
...#.
.....
..S#.

Output Example 1


..#..
.BaA#
.ba#.
.ba..
.bS#.

Input Example 2


2 3
SBA
...

Output Example 2


NA

The goal cell is not an obstacle, so the shortest path to the goal A is only (1,1)(1, 1)(1,2)(1, 2)(1,3)(1, 3). However, that path contains the goal cell B and thus you cannot avoid to use the common cell in the shortest paths. Therefore, you should output NA.


Input Example 3


5 5
..#..
.B.A#
.#.#.
.....
..S#.

Output Example 3


NA

Input Example 4


5 8
.#...#..
.#.#.#..
.S.#...B
.#####A.
........

Output Example 4


.#bbb#..
.#b#b#..
aSb#bbbB
a#####A.
aaaaaaa.