You are given three non-negative integers $X$, $Y$ and $N$. Find the number of integers $Z$ such that $0 \le Z \le N$ and $(X \oplus Z) < (Y \oplus Z)$, where $\oplus$ denotes the bitwise XOR operation.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains three space-separated integers $X$, $Y$ and $N$.

-----Output-----
For each test case, print a single line containing one integer ― the number of integers $Z$ which satisfy all conditions.

-----Constraints-----
- $1 \le T \le 1,000$
- $0 \le X, Y, N \le 2^{30} - 1$

-----Subtasks-----
Subtask #1 (5 points): $X, Y, N \le 2^6 - 1$
Subtask #2 (95 points): original constraints

-----Example Input-----
3
1 2 10
2 1 10
0 0 7

-----Example Output-----
6
5
0

```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 = '# cook your dish here\nfrom random import randint\n\nf = input\n\n# f = open("in.txt", "r").readline\n\n\ndef din(st):\n return bin(st)[2:].zfill(10)\n\n\ndef func(x, y, n):\n # count = 0\n # for z in range(0, n+1):\n #     print(din(x), "xor", din(z), end=" ")\n #     if x ^ z < y ^ z:\n #         count += 1\n #         print("<", end=" ")\n #     else:\n #         print(">=", end="")\n #     print(din(y), "xor", din(z), "z =", z)\n z0 = x ^ 0 < y ^ 0\n unmatch = 1\n # print(z0)\n # print(x ^ unmatch < y ^ unmatch)\n while z0 == (x ^ unmatch < y ^ unmatch) and unmatch < n+1:\n  # print(unmatch < n+1)\n  unmatch *= 2\n  # print("unmatch =", unmatch)\n # print("x y =", x, y)\n # print("unmatch =", unmatch)\n # print("n =", n)\n ans = ((n+1) // (unmatch*2)) * unmatch\n ans += min(unmatch, (n+1)-(ans*2))\n # print("ans =", ans)\n return (ans if z0 else ((n+1)-ans))\n\n\nfor _ in range(int(f())):\n x, y, n = list(map(int, f().split()))\n # x, y = (randint(1, 20), randint(1, 20))\n print(func(x, y, n))\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13279