n = int(eval(input()))

m = int(eval(input()))

print(((5 - n -m)%3 + 1))
print((int(eval(input()))^int(eval(input()))))

n = int(eval(input()))
m = int(eval(input()))
print(((5 - n - m) % 3 + 1))

print((int(eval(input())) ^ int(eval(input()))))

-n = int(eval(input())) -m = int(eval(input())) -print(((5 - n - m) % 3 + 1)) +print((int(eval(input())) ^ int(eval(input()))))