a,b = map(int,input().split())
A = a%4
ans1 = 0
for i in range(A):
    ans1 = ans1^(a-i-1)
B = (b+1)%4
ans2 = 0
for i in range(B):
    ans2 = ans2^(b-i)
print(ans1^ans2) a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b A = a%4 A a%4 a 4 ans1 = 0 ans1 0 for i in range(A):
    ans1 = ans1^(a-i-1) i range(A) range A ans1 = ans1^(a-i-1) ans1 ans1^(a-i-1) ans1 a-i-1 a-i a i 1 B = (b+1)%4 B (b+1)%4 b+1 b 1 4 ans2 = 0 ans2 0 for i in range(B):
    ans2 = ans2^(b-i) i range(B) range B ans2 = ans2^(b-i) ans2 ans2^(b-i) ans2 b-i b i print(ans1^ans2) print ans1^ans2 ans1 ans2 ans2 = ans2^(b-i) ans2^(b-i) ans2 a,b = map(int,input().split()) map(int,input().split()) a B = (b+1)%4 (b+1)%4 B A = a%4 a%4 A ans2 = 0 0 ans2 ans1 = 0 0 ans1 ans1 = ans1^(a-i-1) ans1^(a-i-1) ans1 b = map(int,input().split()) map(int,input().split()) b
a,b = map(int,input().split())
A = a%4
ans1 = 0
for i in range(A):
    ans1 = ans1^(a-i-1)
B = (b+1)%4
ans2 = 0
for i in range(B):
    ans2 = ans2^(b-i)
print(ans1^ans2)