[[問題文>練習問題#x443bc7a]]
 import sys
 N = 7
 mp = [ list(sys.stdin.readline().strip()) for _ in xrange(N) ]
 mp = [ list(raw_input()) for _ in xrange(N) ]
 q = [ (r, c) for c in xrange(N) for r in xrange(N) if mp[r][c] == 'Q' ]
 dr, dc = q[1][0] - q[0][0], q[1][0] - q[1][1]
 nr, nc = q[1][0] + dr, q[1][1] + dc
 while mp[nr%N][nc%N] != 'Q':
   mp[nr%N][nc%N] = 'Q'
   nr += dr
   nc += dc
 nr, nc = (q[1][0] + dr) % N, (q[1][1] + dc) % N
 while mp[nr][nc] != 'Q':
   mp[nr][nc] = 'Q'
   nr = (nr + dr) % N
   nc = (nc + dc) % N
 print '\n'.join(''.join(mp[r]) for r in xrange(N))