n = int(input()) board = [input() for _ in range(n)] all_s = [i for i in range(n) if 'F' not in board[i]] all_f = [i for i in range(n) if 'S' not in board[i]] NEED = n // 4 avail = [] if len(all_s) >= NEED: avail.append((all_s, 'S', 'F')) if len(all_f) >= NEED: avail.append((all_f, 'F', 'S')) chosen, special, other = max(avail, key=lambda x: -len(x[0])) chosen.sort(key=lambda i: -board[i].count(special)) assert len(chosen) >= NEED chosen = chosen[:NEED] for i, row in enumerate(board): for j, cell in enumerate(row): if i == j: print('.', end='') elif i in chosen or j in chosen: assert cell in (special, '?') print(special, end='') elif cell == '?': print(other, end='') else: print(cell, end='') print()