A, B = map(int, input().split())
A -= 1
ak, amod = divmod(A, 4)

cum_a = 0
if amod == 0:
    cum_a = A
elif amod == 1:
    cum_a = 1
elif amod == 2:
    cum_a = 4*ak + 3
else:
    cum_a = 0

bk, bmod = divmod(B, 4)
cum_b = 0
if bmod == 0:
    cum_b = B
elif bmod == 1:
    cum_b = 1
elif bmod == 2:
    cum_b = 4*bk + 3
else:
    cum_b = 0

print(cum_a ^ cum_b) A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B A -= 1 A 1 ak, amod = divmod(A, 4) ak divmod(A, 4) divmod A 4 amod cum_a = 0 cum_a 0 if amod == 0:
    cum_a = A
elif amod == 1:
    cum_a = 1
elif amod == 2:
    cum_a = 4*ak + 3
else:
    cum_a = 0 amod == 0 amod 0 cum_a = A cum_a A elif amod == 1:
    cum_a = 1 amod == 1 amod 1 cum_a = 1 cum_a 1 elif amod == 2:
    cum_a = 4*ak + 3 amod == 2 amod 2 cum_a = 4*ak + 3 cum_a 4*ak + 3 4*ak 4 ak 3 cum_a = 0 cum_a 0 bk, bmod = divmod(B, 4) bk divmod(B, 4) divmod B 4 bmod cum_b = 0 cum_b 0 if bmod == 0:
    cum_b = B
elif bmod == 1:
    cum_b = 1
elif bmod == 2:
    cum_b = 4*bk + 3
else:
    cum_b = 0 bmod == 0 bmod 0 cum_b = B cum_b B elif bmod == 1:
    cum_b = 1 bmod == 1 bmod 1 cum_b = 1 cum_b 1 elif bmod == 2:
    cum_b = 4*bk + 3 bmod == 2 bmod 2 cum_b = 4*bk + 3 cum_b 4*bk + 3 4*bk 4 bk 3 cum_b = 0 cum_b 0 print(cum_a ^ cum_b) print cum_a ^ cum_b cum_a cum_b cum_b = 4*bk + 3 4*bk + 3 cum_b bmod = divmod(B, 4) divmod(B, 4) bmod B = map(int, input().split()) map(int, input().split()) B cum_a = 0 0 cum_a ak, amod = divmod(A, 4) divmod(A, 4) ak cum_a = 4*ak + 3 4*ak + 3 cum_a cum_b = 1 1 cum_b A -= 1 1 A A, B = map(int, input().split()) map(int, input().split()) A cum_a = 0 0 cum_a cum_a = 1 1 cum_a cum_b = 0 0 cum_b cum_b = 0 0 cum_b cum_b = B B cum_b amod = divmod(A, 4) divmod(A, 4) amod cum_a = A A cum_a bk, bmod = divmod(B, 4) divmod(B, 4) bk
A, B = map(int, input().split())
A -= 1
ak, amod = divmod(A, 4)

cum_a = 0
if amod == 0:
    cum_a = A
elif amod == 1:
    cum_a = 1
elif amod == 2:
    cum_a = 4*ak + 3
else:
    cum_a = 0

bk, bmod = divmod(B, 4)
cum_b = 0
if bmod == 0:
    cum_b = B
elif bmod == 1:
    cum_b = 1
elif bmod == 2:
    cum_b = 4*bk + 3
else:
    cum_b = 0

print(cum_a ^ cum_b)