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 = 'for _ in range(int(input())):\n [x,y,n] = list(map(int , input().split()))\n \n if (x==y):\n  print(0)\n else:\n  sn = bin(n)[2:]\n  ln = len(sn)\n\n  sx = bin(x)[2:]\n  lx = len(sx)\n\n  sy = bin(y)[2:]\n  ly = len(sy)\n\n  l = max(ln,lx,ly)\n  \n  sn = \'0\'*(l-ln) + sn\n  sx = \'0\'*(l-lx) + sx\n  sy = \'0\'*(l-ly) + sy\n\n  for i in range(l):\n   if (sx[i] != sy[i]):\n    break\n  #print("i = ",i)\n\n  if (i == 0):\n   t1 = 1\n  else:\n   t1 = int(sn[:i],2)+1\n\n  rstval = 2**(l-i-1)\n\n  #no limits\n  if (sx[i] == \'0\' and sn[i] == \'1\'):\n   print(t1 * rstval)\n  \n  elif (sx[i] == \'1\' and sn[i] == \'1\'):\n   #print(256)\n   if (i == l-1):\n    t2 = 1\n   else:\n    t2 = int(sn[i+1:],2)+1\n   print(t2 + (t1-1)*rstval)\n\n  elif (sx[i] == \'1\' and sn[i] == \'0\'):\n   t2 = rstval\n   print((t1-1)*t2)\n\n  #limits\n  else:\n   if (i == l-1):\n    t2 = 1\n   else:\n    t2 = int(sn[i+1:],2)+1\n   print(t2 + (t1-1)*rstval)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13823