A,B = map(int,input().split())
if A==0:
    fa = 0
else:
    v = (A-1)%4
    fa = 1 if v==2 or v ==1 else 0
    fa = fa ^ (A-1) if v%2==0 else fa
if B==0:
    fb = 0
else:
    v = (B)%4
    fb = 1 if v==2 or v ==1 else 0
    fb = fb ^ B if v%2==0 else fb
print(fa ^ fb) A,B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B if A==0:
    fa = 0
else:
    v = (A-1)%4
    fa = 1 if v==2 or v ==1 else 0
    fa = fa ^ (A-1) if v%2==0 else fa A==0 A 0 fa = 0 fa 0 v = (A-1)%4 v (A-1)%4 A-1 A 1 4 fa = 1 if v==2 or v ==1 else 0 fa 1 if v==2 or v ==1 else 0 v==2 or v ==1 v==2 v 2 v ==1 v 1 1 0 fa = fa ^ (A-1) if v%2==0 else fa fa fa ^ (A-1) if v%2==0 else fa v%2==0 v%2 v 2 0 fa ^ (A-1) fa A-1 A 1 fa if B==0:
    fb = 0
else:
    v = (B)%4
    fb = 1 if v==2 or v ==1 else 0
    fb = fb ^ B if v%2==0 else fb B==0 B 0 fb = 0 fb 0 v = (B)%4 v (B)%4 B 4 fb = 1 if v==2 or v ==1 else 0 fb 1 if v==2 or v ==1 else 0 v==2 or v ==1 v==2 v 2 v ==1 v 1 1 0 fb = fb ^ B if v%2==0 else fb fb fb ^ B if v%2==0 else fb v%2==0 v%2 v 2 0 fb ^ B fb B fb print(fa ^ fb) print fa ^ fb fa fb B = map(int,input().split()) map(int,input().split()) B fa = 1 if v==2 or v ==1 else 0 1 if v==2 or v ==1 else 0 fa v = (B)%4 (B)%4 v fa = 0 0 fa fb = 0 0 fb fb = fb ^ B if v%2==0 else fb fb ^ B if v%2==0 else fb fb fa = fa ^ (A-1) if v%2==0 else fa fa ^ (A-1) if v%2==0 else fa fa fb = 1 if v==2 or v ==1 else 0 1 if v==2 or v ==1 else 0 fb A,B = map(int,input().split()) map(int,input().split()) A v = (A-1)%4 (A-1)%4 v
A,B = map(int,input().split())
if A==0:
    fa = 0
else:
    v = (A-1)%4
    fa = 1 if v==2 or v ==1 else 0
    fa = fa ^ (A-1) if v%2==0 else fa
if B==0:
    fb = 0
else:
    v = (B)%4
    fb = 1 if v==2 or v ==1 else 0
    fb = fb ^ B if v%2==0 else fb
print(fa ^ fb)