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 = '#Coded By Ujjwal Bharti\ndef binary(x):\n result = []\n while x != 0:\n  temp = x%2\n  x = x//2\n  result.append(temp)\n return result\ndef binCount(x):\n count=0\n while x != 0:\n  x = x//2\n  count += 1 \n return count\ndef xnor(a,b):\n final = []\n count = max(binCount(a),binCount(b))\n abin = binary(a)\n bbin = binary(b)\n if count != len(abin):\n  while len(abin) != count:\n   abin.append(0)\n if count != len(bbin):\n  while len(bbin) != count:\n   bbin.append(0)\n #print(abin,bbin)\n i=0\n while i <count:\n  if (bbin[i]==0 and abin[i]==0) or (bbin[i]==1 and abin[i]==1):\n   final.append(1)\n  else:\n   final.append(0)\n  i += 1\n #print(abin,bbin,final)\n ans = 0\n i = 0\n #print(final)\n for dig in final:\n  ans += (dig*(2**i))\n  #print(ans)\n  i += 1\n return ans\n \ntulu = int(input())\nfor _ in range(tulu):\n a,b,n = [int(x) for x in input().split()]\n x = a ^ b\n y = xnor(a,b)\n #print(y)\n value1 = x\n value2 = y\n if n %3==1:\n  value1=a\n  value2=a\n if n%3==2:\n  value2=b\n  value1=b\n print(max(value1,value2))'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13491