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 swap(a,b): \n \n temp=a \n a=b \n b=temp \n \n# log(n) solution \ndef xnor(a, b): \n  \n # Make sure a is larger \n if (a < b): \n  swap(a, b) \n \n if (a == 0 and b == 0) : \n  return 1; \n  \n # for last bit of a \n a_rem = 0 \n  \n # for last bit of b \n b_rem = 0 \n \n # counter for count bit and  \n #  set bit in xnor num \n count = 0\n  \n # for make new xnor number \n xnornum = 0 \n \n # for set bits in new xnor \n # number \n while (a!=0) : \n  \n  # get last bit of a \n  a_rem = a & 1 \n   \n  # get last bit of b \n  b_rem = b & 1 \n \n  # Check if current two  \n  # bits are same \n  if (a_rem == b_rem):      \n   xnornum |= (1 << count) \n   \n  # counter for count bit \n  count=count+1\n   \n  a = a >> 1\n  b = b >> 1\n  \n return xnornum;\n\ndef nthXorFib(n, a, b): \n if n == 0 :  \n  return a \n if n == 1 :  \n  return b \n if n == 2 :  \n  return a ^ b \n \n return nthXorFib(n % 3, a, b)\n\ndef nthXNorFib(n, a, b): \n if n == 0 :  \n  return a \n if n == 1 :  \n  return b \n if n == 2 :  \n  return xnor(a, b)\n \n return nthXNorFib(n % 3, a, b)\n\nfor test in range(int(input())):\n a, b, n = map(int, input().split())\n\n print(max(nthXNorFib(n - 1, a, b), nthXorFib(n - 1, a, b)))'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13647