[[問題文>練習問題#p44d7cef]]
 import sys
 N = 7
 mp = [ list(sys.stdin.readline().strip()) 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
 print '\n'.join(''.join(mp[r]) for r in xrange(N))