A,B = map(int, input().split())

fa = 0
if A%2 == 0 and A%4 == 0:
    fa = 0
elif A%2 == 0 and A%4 != 0:
    fa = 1
elif A%2 != 0 and (A-1)%4 == 0:
    fa = ((A-1) ^ 0)
elif A%2 != 0 and (A-1)%4 != 0:
    fa = (A-1) ^ 1

fb = 0
if (B+1)%2 == 0 and (B+1)%4 == 0:
    fb = 0
elif (B+1)%2 == 0 and (B+1)%4 != 0:
    fb = 1
elif (B+1)%2 != 0 and B%4 == 0:
    fb = (B ^ 0)
elif (B+1)%2 != 0 and B%4 != 0:
    fb = (B ^ 1)

print(fa ^ fb) A,B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B fa = 0 fa 0 if A%2 == 0 and A%4 == 0:
    fa = 0
elif A%2 == 0 and A%4 != 0:
    fa = 1
elif A%2 != 0 and (A-1)%4 == 0:
    fa = ((A-1) ^ 0)
elif A%2 != 0 and (A-1)%4 != 0:
    fa = (A-1) ^ 1 A%2 == 0 and A%4 == 0 A%2 == 0 A%2 A 2 0 A%4 == 0 A%4 A 4 0 fa = 0 fa 0 elif A%2 == 0 and A%4 != 0:
    fa = 1 A%2 == 0 and A%4 != 0 A%2 == 0 A%2 A 2 0 A%4 != 0 A%4 A 4 0 fa = 1 fa 1 elif A%2 != 0 and (A-1)%4 == 0:
    fa = ((A-1) ^ 0) A%2 != 0 and (A-1)%4 == 0 A%2 != 0 A%2 A 2 0 (A-1)%4 == 0 (A-1)%4 A-1 A 1 4 0 fa = ((A-1) ^ 0) fa (A-1) ^ 0 A-1 A 1 0 elif A%2 != 0 and (A-1)%4 != 0:
    fa = (A-1) ^ 1 A%2 != 0 and (A-1)%4 != 0 A%2 != 0 A%2 A 2 0 (A-1)%4 != 0 (A-1)%4 A-1 A 1 4 0 fa = (A-1) ^ 1 fa (A-1) ^ 1 A-1 A 1 1 fb = 0 fb 0 if (B+1)%2 == 0 and (B+1)%4 == 0:
    fb = 0
elif (B+1)%2 == 0 and (B+1)%4 != 0:
    fb = 1
elif (B+1)%2 != 0 and B%4 == 0:
    fb = (B ^ 0)
elif (B+1)%2 != 0 and B%4 != 0:
    fb = (B ^ 1) (B+1)%2 == 0 and (B+1)%4 == 0 (B+1)%2 == 0 (B+1)%2 B+1 B 1 2 0 (B+1)%4 == 0 (B+1)%4 B+1 B 1 4 0 fb = 0 fb 0 elif (B+1)%2 == 0 and (B+1)%4 != 0:
    fb = 1 (B+1)%2 == 0 and (B+1)%4 != 0 (B+1)%2 == 0 (B+1)%2 B+1 B 1 2 0 (B+1)%4 != 0 (B+1)%4 B+1 B 1 4 0 fb = 1 fb 1 elif (B+1)%2 != 0 and B%4 == 0:
    fb = (B ^ 0) (B+1)%2 != 0 and B%4 == 0 (B+1)%2 != 0 (B+1)%2 B+1 B 1 2 0 B%4 == 0 B%4 B 4 0 fb = (B ^ 0) fb B ^ 0 B 0 elif (B+1)%2 != 0 and B%4 != 0:
    fb = (B ^ 1) (B+1)%2 != 0 and B%4 != 0 (B+1)%2 != 0 (B+1)%2 B+1 B 1 2 0 B%4 != 0 B%4 B 4 0 fb = (B ^ 1) fb B ^ 1 B 1 print(fa ^ fb) print fa ^ fb fa fb fa = ((A-1) ^ 0) (A-1) ^ 0 fa fb = 0 0 fb fa = (A-1) ^ 1 (A-1) ^ 1 fa A,B = map(int, input().split()) map(int, input().split()) A fb = (B ^ 1) B ^ 1 fb fb = 1 1 fb fb = (B ^ 0) B ^ 0 fb fa = 0 0 fa fa = 0 0 fa B = map(int, input().split()) map(int, input().split()) B fb = 0 0 fb fa = 1 1 fa
A,B = map(int, input().split())

fa = 0
if A%2 == 0 and A%4 == 0:
    fa = 0
elif A%2 == 0 and A%4 != 0:
    fa = 1
elif A%2 != 0 and (A-1)%4 == 0:
    fa = ((A-1) ^ 0)
elif A%2 != 0 and (A-1)%4 != 0:
    fa = (A-1) ^ 1

fb = 0
if (B+1)%2 == 0 and (B+1)%4 == 0:
    fb = 0
elif (B+1)%2 == 0 and (B+1)%4 != 0:
    fb = 1
elif (B+1)%2 != 0 and B%4 == 0:
    fb = (B ^ 0)
elif (B+1)%2 != 0 and B%4 != 0:
    fb = (B ^ 1)

print(fa ^ fb)