The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2). You have developed two sequences of numbers. The first sequence that uses the bitwise XOR operation instead of the addition method is called the Xoronacci number. It is described as follows:
X(n) = X(n-1) XOR X(n-2)
The second sequence that uses the bitwise XNOR operation instead of the addition method is called the XNoronacci number. It is described as follows:
E(n) = E(n-1) XNOR E(n-2)
The first and second numbers of the sequence are as follows:
X(1) = E(1) = a
X(2) = E(2) = b
Your task is to determine the value of max(X(n),E(n)), where n is the n th term of the Xoronacci and XNoronacci sequence.

-----Input:-----
The first line consists of a single integer T denoting the number of test cases.
The first and the only line of each test case consists of three space separated integers a, b and n.

-----Output:-----
For each test case print a single integer max(X(n),E(n)).

-----Constraints-----
- $1 \leq T \leq 1000$
- $2 \leq a,b,n \leq 1000000000000$

-----Sample Input:-----
1
3 4 2 

-----Sample Output:-----
4

-----EXPLANATION:-----
Xoronacci Sequence : 3 4 7 …….
XNoronacci Sequence : 3 4 0 …….
Here n = 2. Hence max(X(2),E(2)) = 4

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import math \n \ndef togglebit( n): \n \n if (n == 0): \n  return 1\n i = n \n n = n|(n >> 1) \n n |= n >> 2\n n |= n >> 4\n n |= n >> 8\n n |= n >> 16\n \n return i ^ n \ndef xnor( num1, num2): \n  \n # Make sure num1 is larger \n if (num1 < num2): \n  temp = num1 \n  num1 = num2 \n  num2 = temp \n num1 = togglebit(num1) \n  \n return num1 ^ num2 \ndef x(A,B,N):\n if N==1:\n  return A\n elif N==2:\n  return B\n else:\n  t0=A^B\n  t1=B^t0\n  t2=t0^t1\n  if N%3==0:\n   return t0\n  elif N%3==1:\n   return t1\n  else:\n   return t2\n   \ndef xn(A,B,N):\n if N==1:\n  return A\n elif N==2:\n  return B\n else:\n  cache=[xnor(A,B)]\n  cache.append(xnor(cache[0],B))\n  for i in range(2,7):\n   cache.append(xnor(cache[i-1],cache[i-2]))\n  t1=xnor(cache[6],cache[5])\n  t2=xnor(cache[6],t1)\n  t0=xnor(t2,t1)\n  if N<=9:\n   return cache[N-3]\n  else:\n   if N%3==0:\n    return t0\n   elif N%3==1:\n    return t1\n   else:\n    return t2\n \nt=int(input())\nfor _ in range(t):\n p,q,n=map(int,input().split())\n print(max(x(p,q,n),xn(p,q,n)))'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13639