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 = 'testcases = int(input())\nfor testcase in range(testcases):\n temparr = input()\n temparr = temparr.split()\n x = int(temparr[0])\n y = int(temparr[1])\n n = int(temparr[2])\n if x == y:\n  print(0)\n  continue\n binaryx= "{0:b}".format(x)\n binaryy = "{0:b}".format(y)\n nx = len(binaryx)\n ny = len(binaryy)\n maxlen = max(nx, ny)\n binaryx = (maxlen - nx) *"0" + binaryx\n binaryy = (maxlen - ny) *"0" + binaryy\n # print(binaryx)\n # print(binaryy)\n binaryn= "{0:b}".format(n)\n index = 0 \n flag = 0 \n # print(binaryx)\n # print(binaryy)\n for i in range(maxlen):\n  if binaryx[i] == binaryy[i]:\n   continue \n  index = i \n  if binaryy[i] == "0":\n   flag = 1 \n   break \n  \n  break\n arr = []\n for i in range(maxlen):\n  if i == index:\n   arr.append("1")\n  else:\n   arr.append("0")\n newstrs = "".join(arr)\n compareresult = int(newstrs, 2)\n # print("index " + str(index))\n # print("compareresult " + str(compareresult))\n ans = 0 \n for i in range(n + 1):\n  if flag == 1 and ( i & compareresult ):\n   ans += 1 \n  if flag == 0 and ( i & compareresult == 0):\n   ans += 1 \n \n print(ans)\n \n \n \n \n \n \n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13659