Let f(A, B) be the exclusive OR of A, A+1, ..., B. Find f(A, B).
What is exclusive OR?
The bitwise exclusive OR of integers c_1, c_2, ..., c_n (let us call it y) is defined as follows:
 - When y is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if, the number of integers among c_1, c_2, ...c_m whose binary representations have 1 in the 2^k's place, is odd, and 0 if that count is even.
For example, the exclusive OR of 3 and 5 is 6. (When written in base two: the exclusive OR of 011 and 101 is 110.)

-----Constraints-----
 - All values in input are integers.
 - 0 \leq A \leq B \leq 10^{12}

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Compute f(A, B) and print it.

-----Sample Input-----
2 4

-----Sample Output-----
5

2, 3, 4 are 010, 011, 100 in base two, respectively.
The exclusive OR of these is 101, which is 5 in base ten.

Difficulty: interview

Starter code:

Solutions:
def XorWorld():
    a, b = list(map(int, input().split()))
    if a%2 == 0 and b%2 == 0:
        if ((b-a)//2)%2 == 0:
            print((0^b))
        else:
            print((1^b))
    elif a%2 == 0:
        if ((b-a+1)//2)%2 == 0:
            print((0))
        else:
            print((1))
    elif b%2 == 0:
        if ((b-a-1)//2)%2 == 0:
            print((0^a^b))
        else:
            print((1^a^b))
    else:
        if ((b-a)//2)%2 == 0:
            print((0^a))
        else:
            print((1^a))

def __starting_point():
    XorWorld()
    

__starting_point()

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

a,b = list(map(int, input().split()))

# 0からnまでのXOR和
def xor_sum(n):
    ans = 0
    # XORで1になる組数を求める
    if n % 2:
        # 奇数の時は切り上げて偶奇判定
        ans = ((n + 1) // 2) % 2
    else:
        # 偶数の時はnとのXORを返す
        ans = (n // 2) % 2
        ans ^= n
    return ans

print((xor_sum(b) ^ xor_sum(a - 1)))


import sys
input = sys.stdin.readline

A, B = map(int, input().split())
def xor_sum(n):
    ans = 0
    if n % 2:
        ans = ((n+1)//2) % 2
    else:
        ans = (n//2) % 2
        ans ^= n
    return ans

print(xor_sum(A-1) ^ xor_sum(B))

a,b=map(int,input().split());a-=1
print((a^b)>>1&1^[b,1][b&1]^[a,1][a&1])

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

ca=[A//2%2]
i=2
while i<=A:
    i*=2
    x=A%i
    ca.append((2*x>i)*(x%2))

B+=1
cb=[B//2%2]
i=2
while i<=B:
    i*=2
    x=B%i
    cb.append((2*x>i)*(x%2))

ca+=[0]*99
cab=[a^b for a,b in zip(ca,cb)]
print(sum(cab[i]*2**i for i in range(len(cab))))

from math import log2

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

def bitpos(x,digit=1):
  bit = x % (2**digit) // (2**(digit-1))
  pos = x % (2**digit)
  return int(bit),pos

if B == 0:
  print(0)
  return
else:
  max_digit=int(log2(B))+1

xor=[]
for i in range(max_digit):
  abit,apos = bitpos(A,i+1)
  bbit,bpos = bitpos(B,i+1)
  if i == 0:
    ar,br = A%4,B%4
    if (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)}:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  
  if abit == 0 and bbit==0:
    xor.append('0')
    continue
  elif abit == 1 and bbit==0:
    if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  elif abit == 0 and bbit == 1:
    if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  else:
    if abs(apos-bpos) % 2 == 1:
      xor.append('0')
      continue
    else:
      xor.append('1')
      continue
xor = xor[::-1]
print(int(''.join(xor),2))

a, b = list(map(int, input().split()))

def f(n):
    if n%2 == 0:
        n1s = n//2
        return n if n1s%2 == 0 else 1^n
    else:
        n1s = (n+1)//2
        return 0 if n1s%2 == 0 else 1

print(f(b)^f(a-1))

A,B = list(map(int,input().split()))
xor = []
if B-A<=8:
    ans = 0
    for i in range(A,B+1):
        ans^=i
else:
    while True:
        if A%4 == 0:
            break
        else:
            xor.append(A)
        A+=1

    while True:
        if B%4 == 3:
            break
        else:
            xor.append(B)
        B-=1

    ans = 0
    while xor:
        ans^=xor.pop()
print(ans)


a, b = map(int, input().split())
def f(n):
    m = n % 4
    if m == 0:return n
    if m == 1:return 1
    if m == 2:return n + 1
    if m == 3:return 0
print(f(b)^f(a-1))

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

def f(X):
  a, b = divmod(X+1, 2)
  return (a%2)^(X*b)

print(f(max(0, A-1))^f(B))

def abc121_d():
    a, b = map(int, input().split())
    ans = 0
    if b - a < 8:
        for k in range(a, b+1):
            ans ^= k
    else:
        low = (a + 3) // 4
        up = b // 4
        for k in range(a, 4*low):
            ans ^= k
        for k in range(4*up, b+1):
            ans ^= k
    print(ans)

def __starting_point():
    abc121_d()
__starting_point()

A,B = map(int,input().split())
def sumXOR(N):
    rm = N % 4
    if rm == 0:
        k = N
    elif rm == 1:
        k = 1
    elif rm == 2:
        k = N+1
    else:
        k = 0
    return k
print(sumXOR(A-1)^sumXOR(B))

A, B = map(int, input().split())
ans = 0
for i in range(40):
    # 含まれる1の数を数える
    tmp = (B-A) // 2**(i+1) * 2**i
    p = A%(2**(i+1))
    q = (B-A)%(2**(i+1))
    # p から p+qの中で余りが2**i ~ 2**(i+1)-1になる個数を求める
    tmp += max(min(p+q,2**(i+1)-1) - max(p,2**i)+1,0)
    tmp += max(min(p+q,2**(i+1)-1 + 2**(i+1)) - max(p,2**i + 2**(i+1))+1,0)
    ans += (tmp%2) * 2**i
print(ans)

import sys
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())

def rep_xor(x):
    if x%4 == 0:
        return 0^x
    elif x%4 == 1:
        return 1
    elif x%4 == 2:
        return 1^x
    else:
        return 0

if a > 0:
    fa = rep_xor(a-1)
    fb = rep_xor(b)
    ans = fa^fb
else:
    fb = rep_xor(b)
    ans = fb

print(ans)

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def f(x):
        if x % 2:
            if x == 1:
                return 1
            elif max(0, x - 3) % 4 == 0:
                return 0
            else:
                return 1
        else:
            t = f(x - 1)
            return t ^ x

    a, b = list(map(int, input().split()))

    res = f(b) ^ f(a - 1)
    print(res)


def __starting_point():
    resolve()

__starting_point()

A,B=map(int,input().split())
ans=(B-A+(B%2)-(A%2))//2%2^(A*(A%2))^(B*(B%2<1))
print(ans)

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b = MAP()

def f(n):
    if n % 2 == 1:
        if ( (n+1)//2 ) % 2 == 1:
            return 1
        else:
            return 0
    else:
        if ( n//2 ) % 2 == 1:
            return n^1
        else:
            return n

ans = f(a-1)^f(b)
print(ans)

# coding: utf-8

# https://atcoder.jp/contests/abc121


def main():
    A, B = list(map(int, input().split()))

    def xor_1_to_x(x):
        output = [0] * 40

        for k in range(40):
            output[k] = (2**k)*((x+1)//(2**(k+1)))
            output[k] += max(0, (x+1) - ((2**(k+1))*((x+1)//(2**(k+1))) + (2**k)))

        return output

    xor_B = xor_1_to_x(B)
    xor_A_m1 = xor_1_to_x(A-1)
    xor_AtoB = [None] * 40
    for k in range(40):
        xor_AtoB[k] = xor_B[k] - xor_A_m1[k]
        xor_AtoB[k] %= 2

    ans = 0
    for k in range(40):
        ans += xor_AtoB[k] * (2**k)

    return ans


print((main()))


import sys

input = sys.stdin.readline


def g(n):
    if n == -1:
        return 0
    if n == 0:
        return 0
    if n == 1:
        return 1

    b = bin(n)[2:]
    res = 0
    # xxxx10: 01, 10
    if b[-2:] == "10":
        res += 3
    # xxxx11: 01, 10, 11
    elif b[-2:] == "11":
        pass
    # xxxx00 or xxxx01
    else:
        res += int(b[-1])

    for i in range(len(b) - 2):
        if b[i] == "0":
            continue
        if b[-1] == "0":
            res += 1 << (len(b) - 1 - i)
    return res


def main():
    A, B = list(map(int, input().split()))

    if A == B:
        ans = A
    else:
        ans = g(A - 1) ^ g(B)

    print(ans)


def __starting_point():
    main()

__starting_point()


def resolve():
    def f(x):
        res = x % 4
        if res == 0:
            return x
        elif res == 1:
            return 1
        elif res == 2:
            return x + 1
        else:
            return 0

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

    # 累積和の考えで [0, B] - [0, A-1]
    # 数列を4つ区切りでxorすると0になる
    # 0,1,2,3, -> 00, 01, 10, 11  = 0

    ans = f(B) ^ f(A - 1)
    print(ans)


def __starting_point():
    resolve()
__starting_point()

# 54
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def ruiseki_xor(n):
    if n % 2 != 0:
        if (n + 1) // 2 % 2 == 0:
            return 0
        else:
            return 1
    # n は偶数
    return ruiseki_xor(n + 1) ^ (n + 1)


a, b = LI()
# a から b の 和 : (bまでの和) - (a - 1 までの和)
ans = ruiseki_xor(b) ^ ruiseki_xor(a - 1)
print(ans)


from functools import reduce
a,b = map(int,input().split())
a -= 1
print(reduce(lambda x,y:x^y,list(range(a-a%4,a+1))+list(range(b-b%4,b+1))))

A,B = map(int,input().split())
A2 = bin(A)[2:]
B2 = bin(B)[2:]
N = len(B2)
A2 = "0"*(N-len(A2))+A2
C = [0 for _ in range(N)]
T = B-A
for k in range(N):
    ind = A%(2**(k+1))
    if k==0:
        t = T%(2**(k+2))
        s = "01010101"
        c1 = 0
        for i in range(ind,ind+t+1):
            if s[i]=="1":
                c1 += 1
    else:
        t = T%(2**(k+1))
        if ind<2**k:
            if ind+t<2**k:
                c1 = 0
            elif ind+t<2**(k+1):
                c1 = ind+t-(2**k-1)
            else:
                c1 = 2**k
        else:
            if ind+t<2**(k+1):
                c1 = t+1
            elif ind+t<3*(2**k):
                c1 = 2**(k+1)-ind
            else:
                c1 = t-2**k+1
    C[N-1-k] = c1%2
a = 0
for i in range(N):
    a = 2*a+C[i]
print(a)

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

def f(x):
    if x%2==0:
        if (x//2)%2==0:
            ans=x
        else:
            ans=1^x
    else:
        ans=f(x-1)^x
    return ans

ans=f(A-1)^f(B)
print(ans)

A,B = map(int,input().split())
a = A%2>0
b = B%2<1
print((A*a)^(((B-b)-(A-1^a))//2%2)^(B*b))

def r(n):
    t=n%4
    if t==0:
        return n
    if t==1:
        return 1
    if t==2:
        return n+1
    if t==3:
        return 0
a,b=map(int,input().split())
print(r(a-1)^r(b))

a, b = map(int, input().split())
def xor(x):
    num = [0 for i in range(41)]
    for i in range(41):
        temp = (x + 1) // (2 ** (i + 1))
        temp2 = (x + 1) % (2 ** (i + 1))
        num[i] += temp * (2 ** i)
        num[i] += max(temp2 - 2 ** i, 0)
    return num
temp = [0 for i in range(41)]
temp2 = xor(b)
temp3 = xor(a - 1)
for i in range(41):
    temp[i] += temp3[i]
    temp[i] -= temp2[i]
    temp[i] %= 2
ans = 0
for i in range(41):
    ans += temp[i] * 2 ** i
print(ans)

A, B = map(int, input().split())
# ans = 0
# for i in range(40):
#     # 含まれる1の数を数える
#     tmp = (B-A) // 2**(i+1) * 2**i
#     p = A%(2**(i+1))
#     q = (B-A)%(2**(i+1))
#     # p から p+qの中で余りが2**i ~ 2**(i+1)-1になる個数を求める
#     tmp += max(min(p+q,2**(i+1)-1) - max(p,2**i)+1,0)
#     tmp += max(min(p+q,2**(i+1)-1 + 2**(i+1)) - max(p,2**i + 2**(i+1))+1,0)
#     ans += (tmp%2) * 2**i
# print(ans)

def f(N):
    if N % 2 == 1:
        return ((N+1)//2)%2
    else:
        return ((N//2)%2)^N

print(f(A-1)^f(B))

a,b=map(int,input().split())

def xor(n):
  z=n%4
  if z==0:
      return n
  elif z==1:
      return 1
  elif z==2:
      return n+1
  else:
      return 0


xxx=xor(b)^xor(a-1)

print(xxx)

a, b = map(int, input().split())

# 0〜a - 1と0〜bの排他的論理和を考えればいい
# 排他的論理和は4つセットで消える（ぷよぷよのようだ）
def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0

print(solve(a - 1) ^ solve(b))

a, b = list(map(int, input().split()))
if a == b:
    print(a)
else:
    a -= 1
    if a%2 == 0:
        fa = (a//2)%2 ^ a
    else:
        fa = ((a+1)//2)%2
    if b%2 == 0:
        fb = (b//2)%2 ^ b
    else:
        fb = ((b+1)//2)%2
    print((fb ^ fa))


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

# 任意の偶数に関して、n ^ (n+1) = 1
# nが偶数の時最下位ビットのみが異なるので。

num = B - A + 1
ans = 0

if A % 2 == 0:
	ones = num // 2
	
	if ones % 2 == 1:
		ans = 1
	else:
		ans = 0
		
	if num % 2 == 1:
		ans = ans ^ B
		
if A % 2 == 1:
	num -= 1
	
	ones = num // 2
	
	if ones % 2 == 1:
		ans = 1
	else:
		ans = 0
	
	if num % 2 == 1:
		ans = ans ^ B
		
	ans = ans ^ A
	
print(ans)

a,b = map(int, input().split())
bis = [0] * 50
"""
- F(A,B) = F(0,B) ^ F(0,A-1)
- 2m ^ 2m+1 = 1
"""
def F(a):
    if a % 2 == 0:
        x = (a-1)//2
        return (x%2)^a
    else:
        x = a//2
        return x%2
    
ans = F(b)^F(a-1)

print((ans))

a, b = map(int, input().split())
p, q = (a+1)//4, (b+1)//4
x, y = (a+1)%4, (b+1)%4
if abs(a-b) < 4:
    ans = a
    for i in range(a+1, b+1):
        ans ^= i
    print(ans)

else:
    if x == 0:
        ans = a

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

    elif x == 1:
        ans = 0

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

    elif x == 2:
        ans = a
        ans ^= (a+1)
        ans ^= (a+2)

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

    elif x == 3:
        ans = a
        ans ^= (a+1)

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B = LI()

    # 実験した結果
    def f(x):
        rem = x % 4
        if rem == 0:
            return x
        elif rem == 1:
            return 1
        elif rem == 2:
            return x + 1
        elif rem == 3:
            return 0

    ans = f(B) ^ f(A - 1)
    print(ans)

def __starting_point():
    resolve()

__starting_point()

A,B = map(int,input().split())
def sumXOR(N):
    rm = N % 4
    if rm == 0:
        k = N
    elif rm == 1:
        k = 1
    elif rm == 2:
        k = N+1
    else:
        k = 0
    return k
print(sumXOR(A-1)^sumXOR(B))

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = list(map(int, readline().split()))

    def f(x):
        r = (x + 1) % 4
        ans = 0
        for n in range(x, x - r, -1):
            ans ^= n
        return ans

    if A == 0:
        print((f(B)))
    else:
        print((f(B) ^ f(A - 1)))

    return


def __starting_point():
    main()

__starting_point()

A,B=map(int,input().split())
if A%2:
    s1=((A+1)//2)%2
else:
    s1=((A//2)%2)^A
if B%2:
    s2=((B+1)//2)%2
else:
    s2=((B//2)%2)^B
print(s1^s2^A)

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

def f(x):
  res = 0
  while x % 4 != 3:
    res ^= x
    x -= 1
  return res

print(f(A-1)^f(B))

a,b=map(int,input().split())


def F(a:int):
    if a%2==1:
        if a%4==1:
            return 1
        else:
            return 0
    else:
        return F(a+1)^(a+1)
ans=F(a-1)^F(b)
print(ans)

a, b = map(int, input().split())
aq, bq = a % 4, b % 4

ans = 0
for i in range(a, a + (4 - aq)):
    ans ^= i

for i in range(b - bq, b + 1):
    ans ^= i

print(ans)


a,b=list(map(int,input().split()))
#a,b=2,4
#a,b=5,11
#a,b=123,456
#a,b=123456789012, 123456789012

def xor(a,b):
    x=a
    for i in range(a+1,b+1):
        x=x^i
    print(("xor:",x))

ia=len(bin(a))-2
ib=len(bin(b))-2

def px(b,ib):
    bbr=[]
    ip=1
    for i in range(ib):
        ip*=2
        bc=(b//ip)*(ip//2)
        bc+=max((b%ip+1)-(ip//2),0)
        bbr.append(bc)
    return bbr

aar=px(a-1,ib)
bbr=px(b,ib)

c=[0]*ib
ip=1
for i in range(ib):
    ip*=2
    ci=bbr[i]-aar[i]
    c[i]=ci%2

ip=1
csum=0
for i in range(ib):
    csum+=c[i]*ip
    ip*=2
    
print(csum)


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

answer = 0
X = A - 1
Y = B
answer = 0
for i in range(1,41):
    cycle = 2 ** i
    qX = X // cycle
    qY = Y // cycle
    rX = X % cycle
    rY = Y % cycle
    oneX = qX * cycle // 2
    oneY = qY * cycle // 2
    if rX >= cycle // 2:
        oneX += rX - cycle // 2 + 1
    if rY >= cycle // 2:
        oneY += rY - cycle // 2 + 1
    one = oneY - oneX

    if one % 2 == 1 :
        answer += 2 ** (i - 1)
    
print(answer)

import itertools
a, b = list(map(int, input().split()))

def hoge(x: int):
    ans = []
    t = 1
    while x >= t:
        temp = t * (x//(t * 2)) + max(x%(t * 2) - (t - 1), 0)
        ans.append(temp)
        t *= 2
    return ans
ans=0
t=1
for i, j in itertools.zip_longest(hoge(b) , hoge(a-1), fillvalue = 0):
    if (i - j) % 2 == 1:
        ans += t
    t *= 2
print(ans)



a, b = map(int, input().split())

def ff(n):
    tmp = (n + 1) // 2
    tmp %= 2
    if n % 2 == 1:
        return tmp
    else:
        return n ^ tmp
    
ans = ff(a - 1) ^ ff(b)
print(ans)

import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return list(map(int, input().split()))
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    A, B = mi()
    
    A -= 1
    if A % 2 == 1:
        # 偶数個
        if (A // 2) % 2 == 1:
            A = 0
        # 奇数個
        else:
            A = 1
    else:
        if ((A-1) // 2) % 2 == 1:
            A = 0 ^ A
        else:
            A = 1 ^ A

    if B % 2 == 1:
        if (B // 2) % 2 == 1:
            B = 0
        else:
            B = 1
    else:
        if ((B-1) // 2) % 2 == 1:
            B = 0 ^ B
        else:
            B = 1 ^ B

    print((A ^ B))

    return

main()


a,b=map(int,input().split());a-=1
print(a>>1&1 ^ b>>1&1^[b,1][b&1]^[a,1][a&1])

a,b = map(int,input().split())
ans = 0
if b-a<=10:
    for i in range(a,b+1):
        ans ^= i
else:
    while a % 4 != 0:
        ans ^= a
        a += 1
    while b % 4 != 3:
        ans ^= b
        b-= 1
print(ans)

a, b = list(map(int, input().split()))

res = 0
if a % 2 == 1:
    res ^= a
    a += 1
if b % 2 == 0:
    res ^= b
    b -= 1
print((res ^ ((b-a+1)//2)%2))


import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = list(map(int, readline().split()))

    def rec(x):
        if x < 4:
            ans = 0
            for i in range(1, x + 1):
                ans ^= i
            return ans

        p = 0
        y = 1
        while y << 1 <= x:
            y <<= 1
            p += 1

        return (1 << p) * ((x - y + 1) % 2) + rec(x & ~(1 << p))

    if A == 0:
        print((rec(B)))
    else:
        print((rec(B) ^ rec(A - 1)))
    return


def __starting_point():
    main()

__starting_point()

def main():
    A,B = list(map(int,input().split()))
    if A == B:
        return A
    elif A%2 == 0 and B%2 == 0:
        tmp = int((B-A)/2)
        if tmp%2 == 0:
            return 0^B
        else:
            return 1^B
    elif A%2 == 0 and B%2 == 1:
        tmp = int((B-A+1)/2)
        if tmp%2 == 0:
            return 0
        else:
            return 1
    elif A%2 == 1 and B%2 == 0:
        tmp = int((B-A-1)/2)
        if tmp%2 == 0:
            return 0^B^A
        else:
            return 1^B^A
    elif A%2 == 1 and B%2 == 1:
        tmp = int((B-A)/2)
        if tmp%2 == 0:
            return 0^A
        else:
            return 1^A

print((main()))


A,B = map(int,input().split())
l = B - A + 1
if A % 2 == 0:
    if l % 2 == 0:
        if l % 4 == 0:
            ans = 0
        else:
            ans = 1
    elif (l-1) % 4 == 0:
        ans = B
    else:
        ans = B^1
else:
    if l % 2 == 0:
        if (l-2) % 4 == 0:
            ans = A^B
        else:
            ans = A^B^1
    elif (l-1) % 4 == 0:
        ans = A
    else:
        ans = A^1
if A == B:
    ans = A

print(ans)

def xor_from_zero(to):
    fr = 0
    to_copy = to
    b = 2 ** (len(format(to, 'b'))-1)
    while b > 2:
        if to_copy // b > 0:
            fr += b
            to_copy -= b

        b = b // 2

    res = 0
    for a in range(fr, to+1):
        res = res ^ a

    return res

A, B = map(int, input().split())
print(xor_from_zero(A-1)^xor_from_zero(B))

a,b=map(int,input().split())
f=lambda x:[x,1,x+1,0][x%4]
print(f(b)^f(a-1))

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

if m ==0:
    print(0)
    return

nl = m.bit_length()
temp = ["0"]*nl

res= [2,3]
ress = [1,2]
res_ju =0
ress_ju =0

if n % 4 in res:
    res_ju = 1
if m % 4 in ress:
    ress_ju = 1
if res_ju ^ ress_ju ==1:
    temp[nl-1]="1"

mod = 4
for i in range(2,nl+1):
    mod *= 2
    res_ju =0
    ress_ju =0
    nn = n% mod
    mm = m% mod
    if nn % 2==1 and nn % (mod//2) >(mod//4):
        res_ju = 1
    if mm % 2 ==0 and mm % (mod//2)+1 > (mod//4):
        ress_ju = 1
    if res_ju ^ ress_ju ==1:
        temp[nl-i]="1"

result = (''.join(temp))

print(int(result,2))

import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    A,B = NMI()
    
    xA , xB = 0,0
    
    if A == 0 or A == 1:
        xA = 0
    else:
        if A % 4 == 1:
            xA = A - 1
        elif A % 4 == 2:
            xA = 1
        elif A % 4 == 3:
            xA = A
        else:
            xA = 0
    
    if B == 0:
        xB = 0
    else:
        if B % 4 == 1:
            xB = 1
        elif B % 4 == 2:
            xB = B + 1
        elif B % 4 == 3:
            xB = 0
        else:
            xB = B
           
    A_bin = format(xA, '040b')
    B_bin = format(xB, '040b')
    
    ans = ['0' for _ in range(40)]
    
    for i in range(39,-1,-1):
        if int(A_bin[i])+int(B_bin[i])==1:
            ans[i] = '1'
    
    print(int("".join(ans),2))
        
    ###################ここに処理を書く################

def __starting_point():
    main()
__starting_point()

A,B=map(int,input().split())
def xo(n):
    if n%4==0:
        return n
    if n%4==1:
        return 1
    if n%4==2:
        return n+1
    return 0
print(xo(A-1)^xo(B))

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

m = len(format(B, "b"))

a = A
b = B
AA = 0
BB = 0

if A % 2 == 1:
    a = A + 1
    AA = A
if B % 2 == 0:
    b = B - 1
    BB = B
b += 1

t = (b - a) // 2
#print(AA, b, t)
if t % 2 == 0:
    print((AA ^ BB))
else:
    print((AA ^ BB ^ 1))


A, B = [int(_) for _ in input().split()]

def g(n):
    ans = 0
    v = (n // 4) * 4
    for x in range(v, n+1):
        ans ^= x
    return ans 

va = g(A-1)
vb = g(B)

print((va ^ vb))


a,b=map(int,input().split())
print((-a^b)>>1&1^[b,1][b&1]^(a&1)*a)

a, b = map(int, input().split())


"""
10**12 < 2**40
任意の整数について、n ^ (n+1) = 1
"""
def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n

print(f(a-1)^f(b))

a, b = list(map(int, input().split()))
n = len(bin(b)[2:])

ans = [0] * n
for i in range(n):
    value = 2**i
    total = 0

    if not (a//value == b//value):
        if (a//value) % 2 == 0:
            start = a//value + 1
        else:
            total += value-(a%value)
            start = a//value + 2

        if (b//value) % 2 == 0:
            end = b//value - 1
        else:
            total += (b%value) + 1
            end = b//value - 2

        if start == end:
            total += value
        elif start > end:
            pass
        else:
            total += ((end-start+1)//2 + 1)*value

    else:
        if (a//value) % 2 == 1:
            total = b-a+1

    ans[n-i-1] = total%2

print(int("".join(map(str, ans)), 2))

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

a=A%4
b=B%4

ans=0
cnt=0
for i in range(a,4):
    ans=ans^(A+cnt)
    cnt+=1
cnt=0
for i in range(b,-1,-1):
    ans=ans^(B-cnt)
    cnt+=1
print(ans)

import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return list(map(int, input().split()))
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    A, B = mi()
    A -= 1
    ans = 0
    for i in [A, B]:
        if i % 2 == 1:
            # 偶数個
            if (i // 2) % 2 == 1:
                i = 0
            # 奇数個
            else:
                i = 1
        else:
            if ((i-1) // 2) % 2 == 1:
                i = 0 ^ i
            else:
                i = 1 ^ i
        ans ^= i
        
    print(ans)

    return

main()


import sys
from collections import Counter as cc
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    a, b = mi()
    def sxor(x):
        ret = ((x+1)//2)%2
        if x%2 == 0:
            ret ^= x
        return ret
    ans = sxor(b)^sxor(a-1)
    print(ans)


def __starting_point():
    main()
__starting_point()

import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return list(map(int, input().split()))
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    A, B = mi()
    
    A -= 1
    if A % 2 == 1:
        # 偶数個
        if (A // 2) % 2 == 1:
            A = 0
        # 奇数個
        else:
            A = 1
    else:
        if (A // 2) % 2 == 0:
            A = 0 ^ A
        else:
            A = 1 ^ A

    if B % 2 == 1:
        if (B // 2) % 2 == 1:
            B = 0
        else:
            B = 1
    else:
        if (B // 2) % 2 == 0:
            B = 0 ^ B
        else:
            B = 1 ^ B

    print((A ^ B))

    return

main()


import math

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

a_p = math.ceil(A/4)
b_p = math.floor(B/4)

ans = 0

for i in range(A, 4*a_p):
    ans = ans ^ i
for j in range(b_p*4, B+1):
    ans = ans ^ j
print(ans)

A, B = list(map(int, input().split()))
# F(A,B) = F(0,A-1) ^ F(0,B)
# 任意の偶数について、n ^ (n+1) = 1
# ex. F(0,6) = 0^1^2^3^4^5^6 = (0^1)^(2^3)^(4^5)^6 = 1^1^1^6
# 1^1^1^...について、1が偶数個なら0, 奇数個なら1


def xor_func(n):
    if n % 2 == 0:
        tmp = n // 2
        if tmp % 2 == 0:
            x = 0 ^ n
        else:
            x = 1 ^ n
    else:
        tmp = (n + 1) // 2
        if tmp % 2 == 0:
            x = 0
        else:
            x = 1
    return x

f1 = xor_func(A - 1)
f2 = xor_func(B)
ans = f1 ^ f2
print(ans)


import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    A, B = NMI()
    C = [[0]*2 for _ in range(42)]
    B = B + 1
    for i in range(42):
        tmp = B - (B // (2**(i+1))) * 2**(i+1)
        if tmp < 2**i:
            C[i][0] = tmp + (B // (2**(i+1))) * 2**i
            C[i][1] = (B // (2 ** (i + 1))) * 2 ** i
        else:
            C[i][0] = 2**i + (B // (2**(i+1))) * 2**i
            C[i][1] = tmp - 2**i + (B // (2**(i+1))) * 2**i


    B = A
    for i in range(42):
        tmp = B - (B // (2**(i+1))) * 2**(i+1)
        if tmp < 2**i:
            C[i][0] -= tmp + (B // (2**(i+1))) * 2**i
            C[i][1] -= (B // (2 ** (i + 1))) * 2 ** i
        else:
            C[i][0] -= 2**i + (B // (2**(i+1))) * 2**i
            C[i][1] -= tmp - 2**i + (B // (2**(i+1))) * 2**i
    ans = 0
    for i in range(42):
        ans += C[i][1] % 2 * 2**i
    print(ans)


def __starting_point():
    main()
__starting_point()

a,b=map(int,input().split())
c,d=0,0
if a%2==1:c=a;a+=1
if b%2==0:d=b;b-=1
print((b-a+1)//2%2^c^d)

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

def solve(A):
    ret=0
    res=1
    if A%4==1 or A%4==2:
        ret+=res
    dig=A%2
    res<<=1
    A>>=1
    while A>0:
        if dig==0 and A%2==1:
            ret+=res
        res<<=1
        A>>=1
    return ret

print((solve(B)^solve(A-1)))


import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = list(map(int, readline().split()))

    def f(x):
        r = (x + 1) % 4
        ans = 0
        for i in range(x, x - r, -1):
            ans ^= i

        return ans

    if A == 0:
        print((f(B)))
    else:
        print((f(B) ^ f(A - 1)))
    return


def __starting_point():
    main()

__starting_point()

a,b=map(int,input().split())

def culc(x):
    if x%4==0:
        return x
    elif x%4==1:
        return 1
    elif x%4==2:
        return x+1
    else:
        return 0


print(culc(a-1)^culc(b))

A, B = list(map(int, input().split()))
# a = A
# if A == B:
#     print(A)
#     return
# if A != 0:
#     a = A - 1
# if a % 2 != 0:
#     a = a ^ (a - 1)
#     t = (a - 1) // 2
#     if t % 2 != 0:
#         a = a ^ 1
# else:
#     t = A // 2
#     if t % 2 != 0:
#         a = a ^ 1
#
# if B % 2 != 0:
#     B = B ^ (B - 1)
#     t = (B - 1) // 2
#     if t % 2 != 0:
#         B = B ^ 1
# else:
#     t = B // 2
#     if t % 2 != 0:
#         B = B ^ 1
# ans = a ^ B
def calc(a):
    t = (a + 1) // 2
    ans = t % 2
    if a % 2 == 0:
        ans = ans ^ a
    return ans

print((calc(A-1) ^ calc(B)))


a,b = list(map(int,input().split()))
if a % 2 == 0:
    if (b - a + 1) % 2 == 0:
        if (b-a + 1) % 4 == 0:
            print((0))
        else:
            print((1))
    else:
        if (b - a) % 4 == 0:
            print((0^b))
        else:
            print((1^b))
else:
    if (b - a) % 2 == 0:
        if (b-a) % 4 == 0:
            print((a^0))
        else:
            print((a^1))
    else:
        if (b - a - 1) % 4 == 0:
            print((0^b^a))
        else:
            print((1^b^a))


from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b = MAP()
a -= 1

s = deque()
tmp = (b+1)//2-(a+1)//2
s.appendleft(str(tmp % 2))
i = 1
while 2**i <= b:
    x = max(0, a%(2**(i+1)) - (2**i-1))
    y = max(0, b%(2**(i+1)) - (2**i-1))
    tmp = y - x
    s.appendleft(str(tmp % 2))
    i += 1
t = list(s)
ans = "".join(t)
print(int(ans, 2))

def main():
	A, B = [int(n) for n in input().split(" ")]
	d = B - A
	if d == 0:
		print(A)
		return 0
	if d == 1:
		print(A ^ B)
		return 0
	begin = A + A % 2
	end = B + B % 2 - 1
	pair = int((end - begin + 1) / 2)
	print((A * (A % 2)) ^ pair % 2 ^ (B * (1 - B % 2)))

main()

A,B=list(map(int,input().split()))
C,D,s=0,0,B-A+1
C=0 if A%2==0 else A
D=0 if B%2==1 else B
if ((s-(0 if C==0 else 1)-(0 if D==0 else 1))//2)%2==0:
   E=0
else:
   E=1
print((C^D^E))


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

def f(X):
  a = 1
  temp = 2
  ret = []
  while a > 0:
    a, b = divmod(X+1, temp)
    if temp == 2:
      ret.append(a%2)
    else:
      ret.append(max(b-(temp//2), 0)%2)
    temp *= 2
  return "".join(map(str, reversed(ret)))

print(int(f(max(0, A-1)), 2)^int(f(B), 2))

import sys
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())

def calc(a):
    if a <= 0: return 0
    
    # 4のときに0,1,2,3,4までになるので、これは5つの整数
    a += 1
    
    ans = 0
    # i桁目の偶奇を調べる
    # 10^3 <= 2^10
    # 10^12 <= 2進数で40桁くらい
    for i in range(50):
        
        # 0桁目 周期2, 1桁目 周期4, 2桁目 周期8
        loop = (1 << (i+1))
        cnt = a//loop * loop//2 # loopした回数×1が出てくる回数
        # 0000....001111....11
        cnt += max(0, (a%loop) - (loop//2))
        # その桁の1の数が奇数だったら足し算
        if cnt%2 == 1:
            ans += 1<<i
            
    return ans
        
ans = calc(a-1)^calc(b)

print(ans)

a, b = map(int, input().split())

def f(x):
    res = 0
    while x % 4 != 3:
        res ^= x
        x -= 1
    
    return res

print(f(a - 1) ^ f(b))

a1,b1=list(map(int,input().split()))
a=[0]*40
b=[0]*40
A=a1
B=b1
for i in range(1,41):
    a[-i]=a1%2
    b[-i]=b1%2
    a1=a1//2
    b1=b1//2
ans=[0]*40
if a[-1]==1:
    if (a[-2]-b[-2])%2==0:
        if b[-1]==1:
            ans[-1]=1
    else:
        if b[-1]==0:
            ans[-1]=1
else:
    if (a[-2]-b[-2])%2==0:
        if b[-1]==1:
            ans[-1]=1
    else:
        if b[-1]==0:
            ans[-1]=1
for i in range(2,41):
    if a[-i]==1 and a[-1]==1:
        if b[-i]==1 and b[-1]==0:
            ans[-i]=0
        else:
            ans[-i]=1
    else:
        if b[-i]==1 and b[-1]==0:
            ans[-i]=1
        else:
            ans[-i]=0
ans1=0
for i in range(1,41):
    ans1+=(2**(i-1))*ans[-i]
print(ans1)


def main():
    a,b = list(map(int,input().split()))
    def f(n):
        if n%4==0:
            return n
        if n%4==1:
            return 1
        if n%4==2:
            return n + 1
        if n%4==3:
            return 0
    print((f(b)^f(a-1)))

def __starting_point():
    main()

__starting_point()

import sys

input = sys.stdin.readline


def g(N):
    if N == -1:
        return 0
    r = N % 4
    if r == 0:
        return N
    elif r == 1:
        return 1
    elif r == 2:
        return N + 1
    else:
        return 0


def main():
    A, B = list(map(int, input().split()))
    ans = g(A - 1) ^ g(B)
    print(ans)


def __starting_point():
    main()

__starting_point()

a,b = list(map(int, input().split()))

# 2n と 2n+1 のxorは1になることを利用
if a%2 == 0:
    ans = 0
    q,r = divmod(b-a+1, 2)
else:
    ans = a
    q,r = divmod(b-a, 2)

if q & 1:
    ans ^= 1
else:
    ans ^= 0
if r:
    ans ^= b

print(ans)

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

i_num=100

def get_one(N,i_num=i_num):
    n_list=[0]*i_num

    for i in range(i_num):
        N_ = N
        if 2**i > N_:
            break
        if (N_//2**i) % 2 == 0:
            N_ = (2**i)*(N//2**i)-1

        n_list[i] = (((N_//(2**i))-1)//2)*2**i + N_%(2**i)+1
    return(n_list)

B_=get_one(B)
A_=get_one(A-1)

ans_ = [0]*i_num
for i in range(i_num):
    if (B_[i] - A_[i]) % 2 != 0:
        ans_[i] = 1
        
ans_.reverse()
ans=''.join(map(str,ans_))

print(int(ans,2))

a,b=map(int,input().split())
a-=1

def allx(n):
    ans=0
    for i in range(40):
        if i==0:
            if n%4==2 or n%4==1:
                ans+=1
                continue
        c= pow(2,i+1)
        k=n% c
        
        if k>=c//2 and k%2==0:
          ans+=pow(2,i)
    return ans

print(allx(b)^allx(a))

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

a,b = list(map(int, input().split()))

bt = 0
if b % 2:
    bt = ((b + 1) // 2) % 2
else:
    bt = (b // 2) % 2
    bt ^= b

at = 0
if (a - 1) % 2:
    at = (a // 2) % 2
else:
    at = ((a - 1) // 2) % 2
    at ^= (a - 1)

print((bt ^ at))


a,b = map(int,input().split())
c,d = map(lambda x:(x//2)%2^1 if x%2 else x^(x//2)%2,[a-1,b])
print(c^d)

# just copy and paste from https://atcoder.jp/contests/abc121/submissions/15377652
for i in range(pow(10,6)):
    pass
# added due to avoid search list with duplicated solvers.

a,b = map(int,input().split())
if a % 2 == 0:
    if (b - a + 1) % 2 == 0:
        if (b-a + 1) % 4 == 0:
            print(0)
        else:
            print(1)
    else:
        if (b - a) % 4 == 0:
            print(0^b)
        else:
            print(1^b)
else:
    if (b - a) % 2 == 0:
        if (b-a) % 4 == 0:
            print(a^0)
        else:
            print(a^1)
    else:
        if (b - a - 1) % 4 == 0:
            print(0^b^a)
        else:
            print(1^b^a)

a,b=map(int,input().split())
if a%2==0 and b%2==0:
  if (b-a)%4==0:
    print(b)
  else:
    print(b^1)
elif a%2==0:
  if (b-a)%4==1:
    print(1)
  else:
    print(0)
elif b%2==0:
  if (b-a)%4==1:
    print(a^b)
  else:
    print(a^b^1)
else:
  if (b-a)%4==0:
    print(a)
  else:
    print(a^1)

a,b=map(int,input().split());print(-(a^b)>>1&1^~b%2*b^a%2*a)

# 偶数a ^ (a + 1)　は必ず1になる
# 従い、0 〜 4の倍数 - 1でXORは0になる

import sys
readline = sys.stdin.readline

A,B = list(map(int,readline().split()))

def f(x):
  res = 0
  while x % 4 != 3:
    res ^= x
    x -= 1
  return res

print((f(A - 1) ^ f(B)))


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

if (A%2==0) and (B%2==0):
  if (B-A) % 4 == 0:
    print(B)
  else:
    print(B+1)
elif (A%2==0) and (B%2==1):
  if (B-A+1) % 4 == 0:
    print(0)
  else:
    print(1)
elif (A%2==1) and (B%2==0):
  if (B-A-1) % 4 == 0:
    print(A^B)
  else:
    print(A^B^1)
else:
  if (B-A) % 4 == 0:
    print(A)
  else:
    print(A^1)

#!/usr/bin/env python3
a, b = list(map(int, input().split()))
"""
bit ごとにみる
b-a = even and a%2 == 0 => 1
else: 0

（0 ~ b madeno 個数）－　（0 ~ a-1 madeno 個数）
1の位は (b+1)/2
10の位は (b+1)/4 + max((b+1)%4-2,0)
100の位
"""

ans = 0
# 0からbまでのxor
if b % 2 == 1:
    ans = (b + 1) // 2 % 2
else:
    ans = b ^ (b // 2 % 2)

# 0からa-1までのxorを掛ける
if a == 0:
    print(ans)
else:
    tmp = 0
    if (a - 1) % 2 == 1:
        tmp = a // 2 % 2
    else:
        tmp = (a - 1) ^ ((a - 1) // 2 % 2)
    ans = ans ^ tmp
    print(ans)


a, b = map(int, input().split())

def xor(n):
    m = n % 4
    if m == 0:
        return n
    elif m == 1:
        return 1
    elif m == 2:
        return n+1
    else:
        return 0

print(xor(a-1)^xor(b))