# 初始化暫存器和主記憶體
registers = [0] * 4
memory = [0] * 8
# 讀入主記憶體初始值
for i in range(8):
memory[i] = int(input())
# 讀入指令數量
N = int(input())
# 讀入並執行指令
for _ in range(N):
instruction = input().split()
cmd = instruction[0]
if cmd == "LOAD":
RD = int(instruction[1])
MS = int(instruction[2])
registers[RD] = memory[MS]
elif cmd == "STORE":
MD = int(instruction[1])
RS = int(instruction[2])
memory[MD] = registers[RS]
elif cmd == "ADD":
RD = int(instruction[1])
RS1 = int(instruction[2])
RS2 = int(instruction[3])
registers[RD] = registers[RS1] + registers[RS2]
elif cmd == "MOVE":
RD = int(instruction[1])
RS = int(instruction[2])
registers[RD] = registers[RS]
# 輸出結果
print(registers[0])
print(memory[0])