問題文

N = 7
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) % 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))