2022-12-05 08:28:30 +00:00
|
|
|
import sys
|
|
|
|
from collections import deque
|
|
|
|
# init data structure
|
|
|
|
S = list()
|
|
|
|
for _ in range(9):
|
|
|
|
S.append(deque())
|
|
|
|
# parse initial positions
|
|
|
|
for _ in range(8):
|
|
|
|
line = next(sys.stdin)
|
|
|
|
for j in range(9):
|
|
|
|
c = line[4*j+1]
|
|
|
|
if c != " ":
|
|
|
|
S[j].append(c)
|
2022-12-06 14:04:45 +00:00
|
|
|
next(sys.stdin)
|
|
|
|
next(sys.stdin)
|
2022-12-05 08:28:30 +00:00
|
|
|
# process
|
|
|
|
while line := sys.stdin.readline():
|
|
|
|
_, q, _, f, _, t = line.strip().split(" ")
|
|
|
|
tmp = deque()
|
|
|
|
for _ in range(int(q)):
|
|
|
|
tmp.append(S[int(f)-1].popleft())
|
|
|
|
for _ in range(int(q)):
|
|
|
|
S[int(t)-1].appendleft(tmp.pop())
|
|
|
|
# print final positions
|
|
|
|
print("".join(s.popleft() for s in S))
|