n, m = map(int, input().split())

def cumXOR(k):
    if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0

print(cumXOR(n-1)^cumXOR(m)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m def cumXOR(k):
    if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0 cumXOR if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0 k % 4 == 0 k % 4 k 4 0 return k k elif k % 4 == 1:
        return 1
     k % 4 == 1 k % 4 k 4 1 return 1 1 elif k % 4 == 2:
        return k + 1
     k % 4 == 2 k % 4 k 4 2 return k + 1 k + 1 k 1 return 0 0 k k print(cumXOR(n-1)^cumXOR(m)) print cumXOR(n-1)^cumXOR(m) cumXOR(n-1) cumXOR n-1 n 1 cumXOR(m) cumXOR m m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n def cumXOR(k):
    if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0 def cumXOR(k):
    if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0 cumXOR
n, m = map(int, input().split())

def cumXOR(k):
    if k % 4 == 0:
        return k
    elif k % 4 == 1:
        return 1
    elif k % 4 == 2:
        return k + 1
    else:
        return 0

print(cumXOR(n-1)^cumXOR(m))
