A,B = (int(x) for x in input().split())
if A == 0:
    m = B % 4
    if m == 0:
        print(B)
    elif m == 1:
        print('1')
    elif m == 2:
        print(B^1)
    else:
        print('0')
else:
    ma = (A-1) % 4
    mb = B % 4
    if ma == 0:
        xora = A-1
    elif ma == 1:
        xora = 1
    elif ma == 2:
        xora = (A-1) ^ 1
    else:
        xora = 0
    if mb == 0:
        xorb = B
    elif mb == 1:
        xorb = 1
    elif mb == 2:
        xorb = B ^ 1
    else:
        xorb = 0
    print(xora^xorb) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x A,B = (int(x) for x in input().split()) A (int(x) for x in input().split()) B if A == 0:
    m = B % 4
    if m == 0:
        print(B)
    elif m == 1:
        print('1')
    elif m == 2:
        print(B^1)
    else:
        print('0')
else:
    ma = (A-1) % 4
    mb = B % 4
    if ma == 0:
        xora = A-1
    elif ma == 1:
        xora = 1
    elif ma == 2:
        xora = (A-1) ^ 1
    else:
        xora = 0
    if mb == 0:
        xorb = B
    elif mb == 1:
        xorb = 1
    elif mb == 2:
        xorb = B ^ 1
    else:
        xorb = 0
    print(xora^xorb) A == 0 A 0 m = B % 4 m B % 4 B 4 if m == 0:
        print(B)
    elif m == 1:
        print('1')
    elif m == 2:
        print(B^1)
    else:
        print('0') m == 0 m 0 print(B) print B elif m == 1:
        print('1')
     m == 1 m 1 print('1') print '1' elif m == 2:
        print(B^1)
     m == 2 m 2 print(B^1) print B^1 B 1 print('0') print '0' ma = (A-1) % 4 ma (A-1) % 4 A-1 A 1 4 mb = B % 4 mb B % 4 B 4 if ma == 0:
        xora = A-1
    elif ma == 1:
        xora = 1
    elif ma == 2:
        xora = (A-1) ^ 1
    else:
        xora = 0
     ma == 0 ma 0 xora = A-1 xora A-1 A 1 elif ma == 1:
        xora = 1
     ma == 1 ma 1 xora = 1 xora 1 elif ma == 2:
        xora = (A-1) ^ 1
     ma == 2 ma 2 xora = (A-1) ^ 1 xora (A-1) ^ 1 A-1 A 1 1 xora = 0 xora 0 if mb == 0:
        xorb = B
    elif mb == 1:
        xorb = 1
    elif mb == 2:
        xorb = B ^ 1
    else:
        xorb = 0
     mb == 0 mb 0 xorb = B xorb B elif mb == 1:
        xorb = 1
     mb == 1 mb 1 xorb = 1 xorb 1 elif mb == 2:
        xorb = B ^ 1
     mb == 2 mb 2 xorb = B ^ 1 xorb B ^ 1 B 1 xorb = 0 xorb 0 print(xora^xorb) print xora^xorb xora xorb xorb = B ^ 1 B ^ 1 xorb mb = B % 4 B % 4 mb xorb = 0 0 xorb xora = 0 0 xora xora = (A-1) ^ 1 (A-1) ^ 1 xora ma = (A-1) % 4 (A-1) % 4 ma B = (int(x) for x in input().split()) (int(x) for x in input().split()) B A,B = (int(x) for x in input().split()) (int(x) for x in input().split()) A m = B % 4 B % 4 m xora = A-1 A-1 xora xora = 1 1 xora xorb = B B xorb xorb = 1 1 xorb
A,B = (int(x) for x in input().split())
if A == 0:
    m = B % 4
    if m == 0:
        print(B)
    elif m == 1:
        print('1')
    elif m == 2:
        print(B^1)
    else:
        print('0')
else:
    ma = (A-1) % 4
    mb = B % 4
    if ma == 0:
        xora = A-1
    elif ma == 1:
        xora = 1
    elif ma == 2:
        xora = (A-1) ^ 1
    else:
        xora = 0
    if mb == 0:
        xorb = B
    elif mb == 1:
        xorb = 1
    elif mb == 2:
        xorb = B ^ 1
    else:
        xorb = 0
    print(xora^xorb)