import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Main {
public static class Pair {
int i , j;
char direction;
public Pair(int i , int j) {
this.i = i;
this.j = j;
}
public Pair(int i , int j , char c) {
this.i = i;
this.j = j;
this.direction = c;
}
}
static char[][] grid = new char[110][110];
static boolean[][] visited = new boolean[110][110];
static ArrayList<Pair> toflood = new ArrayList<Pair>(150);
static ArrayList<Pair> Is = new ArrayList<Pair>(150);
static LinkedList<Pair> q = new LinkedList<Pair>();
static int[] dx = {-1, -1, 0, 0, 1, 1};
static int[] dy = {0, 1, -1, 1, -1, 0};
static boolean l = false;
static int n , m;
// StringTokenizer st = new StringTokenizer(br.readLine());
while(true) {
n
= Integer.
parseInt(st.
nextToken()); m
= Integer.
parseInt(st.
nextToken()); if(n == 0 && m == 0)
break;
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < m ; j++) {
grid[i][j] = temp.charAt(j);
if(grid[i][j] == 'I') {
Is.add(new Pair(i , j , '('));
// grid[i][j] = '(';
}
}
}
// for(int i = 0 ; i < n ; i++) {
// for(int j = 0 ; j < m ; j++) {
// System.out.print(grid[i][j] + " ");
// }
// System.out.println();
// }
for(int i = 0 ; i < Is.size() ; i++) {
q.add(Is.get(i));
bfs();
}
if (l)
sb.append('\n');
sb.append('\n');
for(int i = 0 ; i < toflood.size() ; i++) {
Pair curr = toflood.get(i);
floodfill(curr.i , curr.j);
}
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < m ; j++) {
if(grid[i][j] == '*')
sb.append("F");
else
sb.append(grid[i][j]);
}
if (i != (n - 1))
sb.append('\n');
}
// System.out.println(toflood.isEmpty());
q.clear();
toflood.clear();
Is.clear();
l = true;
for(int i = 0 ; i < n ; i++)
Arrays.
fill(visited
[i
],
false); }
}
public static void floodfill(int i, int j) {
if(i < 0 || i >= n || j < 0 || j >= m)
return;
if(grid[i][j] != '(' && grid[i][j] != ')' && grid[i][j] != '*')
return;
grid[i][j] = 'B';
for(int k = 0 ; k < dx.length ; k++) {
floodfill(i + dx[k], j + dy[k]);
}
}
public static void bfs() {
while(!q.isEmpty()) {
Pair curr = q.poll();
if((grid[curr.i][curr.j] == '(' && curr.direction == ')') || (grid[curr.i][curr.j] == ')' && curr.direction == '(')) {
toflood.add(new Pair(curr.i, curr.j));
q.clear();
continue;
}
else {
grid[curr.i][curr.j] = curr.direction;
}
if(visited[curr.i][curr.j])
continue;
visited[curr.i][curr.j] = true;
char newdirection;
if(curr.direction == ')')
newdirection = '(';
else
newdirection = ')';
for(int j = 0 ; j < dx.length ; j++) {
int newI = curr.i + dx[j];
int newJ = curr.j + dy[j];
if(newI >= 0 && newI < n && newJ >= 0 && newJ < m && grid[newI][newJ] != '.') {
q.add(new Pair(newI , newJ , newdirection));
}
}
}
}
}