Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows:   $f(0) = a$;  $f(1) = b$;  $f(n) = f(n-1) \oplus f(n-2)$ when $n > 1$, where $\oplus$ denotes the bitwise XOR operation. 

You are given three integers $a$, $b$, and $n$, calculate $f(n)$.

You have to answer for $T$ independent test cases.


-----Input-----

The input contains one or more independent test cases.

The first line of input contains a single integer $T$ ($1 \le T \le 10^3$), the number of test cases.

Each of the $T$ following lines contains three space-separated integers $a$, $b$, and $n$ ($0 \le a, b, n \le 10^9$) respectively.


-----Output-----

For each test case, output $f(n)$.


-----Example-----
Input
3
3 4 2
4 5 0
325 265 1231232

Output
7
4
76



-----Note-----

In the first example, $f(2) = f(0) \oplus f(1) = 3 \oplus 4 = 7$.

Difficulty: competition

Starter code:

Solutions:
T = int(input())
for t in range(T):
    a, b, n = [int(i) for i in input().split()]
    if n%3 == 2:
        print(a^b)
    elif n%3 == 1:
        print(b)
    else:
        print(a)


t = int(input())
for i in range(t):
    a, b, n = map(int, input().split())
    if n % 3 == 0:
        print(a)
    elif n % 3 == 1:
        print(b)
    else:
        print(b ^ a)

def main():
    import sys
    input = sys.stdin.readline
    
    for _ in range(int(input())):
        a, b, n = map(int, input().split())
        n %= 3
        if n == 0:
            print(a)
        elif n == 1:
            print(b)
        else:
            print(a^b)
    
    return 0

main()

for _ in range(int(input())):
    a, b, n = map(int, input().split())
    l = [a, b, a ^ b]
    print(l[(n) % 3])

t = int( input() )
for _ in range(t):
    a, b, n = list(map( int, input().split() ))
    l = [ a, b, a ^ b ]
    print( l[ n % 3 ] )


for _ in range(int(input())):
    a,b,n=map(int,input().split())
    if n%3==0:
        print(a)
    elif n%3==1:
        print(b)
    else :
        print(a^b)

def iA():
    n=[int(x) for x in input().split()]
    return n
def iI():
    n=int(input())
    return n
def iS():
    n=input()
    return n
def iAA(numArrs):
    n=[]
    for i in range(numArrs):
        m=iA()
        n.append(m)
    return n
def pA(arr):
    for i in range(len(arr)):
        print(arr[i],end=" ")
    print()

for i in range(iI()):
    r=iA()
    t=r[0]^r[1]
    if r[2]%3==0:
        print(r[0])
    elif r[2]%3==1:
        print(r[1])
    else:
        print(r[0]^r[1])

#
# Yet I'm feeling like
# 	There is no better place than right by your side
# 		I had a little taste
# 			And I'll only spoil the party anyway
# 				'Cause all the girls are looking fine
# 					But you're the only one on my mind


import sys
# import re
# inf = float("inf")
# sys.setrecursionlimit(1000000)

# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0],[0,0,1,-1]

# from collections import deque, Counter, OrderedDict,defaultdict
# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
# from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan
# from bisect import bisect_left,bisect_right
# import numpy as np


def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

T=int(input())
while T>0:
    a,b,n=get_ints()
    n=n%3
    if n==0:
        print(a)
    elif n==1:
        print(b)
    else:
        print(a^b)
    T-=1


from math import gcd, ceil, log, log2
from collections import deque
from bisect import bisect_right, bisect_left
for _ in range(int(input())):
    a, b, n = map(int, input().split())
    if n % 3 == 0:
        print(a)
    elif n % 3 == 1:
        print(b)
    else:
        print(a ^ b)

for _ in range(int(input())):
	a,b,n = [int(i) for i in input().split()]
	print([a,b,a^b][n%3])

t = int(input())
for qury in range(t):
  A = [0] * 3
  A[0], A[1], n = list(map(int, input().split()))
  A[2] = A[0] ^ A[1]
  print(A[n % 3])


for _ in range(int(input())):
    a,b,n =(int(s) for s in input().split())
    l= [a,b,a^b]
    print(l[n%3])

import sys
input = lambda: sys.stdin.readline().strip()

T = int(input())
for i in range(T):
    a, b, n = list(map(int, input().split()))
    if n%3==0: print(a)
    elif n%3==1: print(b)
    else: print(a^b)


t=int(input())
for _ in range(t):
    a,b,n=map(int,input().split())
    if n%3==0:
        print(a)
    elif n%3==1:
        print(b)
    else:
        print(a^b)

for _ in range(int(input())):
    a,b,n=[int(i) for i in input().split()]
    n%=3
    arr=[a,b,a^b]
    print(arr[n])

t=int(input())
for nt in range(t):
	a,b,n=map(int,input().split())
	c=a^b
	if n%3==0:
		print (a)
	elif n%3==1:
		print (b)
	else:
		print (c)

t=int(input())
for I in range(t):
    a,b,n=[int(i) for i in input().split()]
    if(n%3==0):
        print(a)
    elif(n%3==1):
        print(b)
    else:
        print(a^b)


for t in range(int(input())):
    a,b,n = list(map(int,input().split()))
    c = a^b
    ans = [a,b,c]
    print(ans[n%3])

from sys import stdin
t=int(stdin.readline().strip())
for i in range(t):
    a,b,n=list(map(int,stdin.readline().strip().split()))
    x=a^b
    arr=[a,b,x]
    n=n%3
    print(arr[n])
    
    


for T in range(int(input())):
    a, b, n = [int(x) for x in input().split()]

    if n % 3 == 0:
        print(a)
    elif n % 3 == 1:
        print(b)
    else:
        print(a ^ b)


#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    t = int(input())
    for _ in range(t):
        a,b,n= map(int,input().split())
        f = [a , b  , a^b]
        print(f[n%3])
    return

def __starting_point():
    main()
__starting_point()

for cas in range(int(input())):
    x, y, z = map(int, input().split())
    print([x, y, x ^ y][z % 3])