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 = "t = int(input())\nfor i in range(t):\n x,y,n = [int(i) for i in input().split()]\n \n bx = list(bin(x))\n by = list(bin(y))\n bx.remove(bx[0])\n bx.remove(bx[0])\n by.remove(by[0])\n by.remove(by[0])\n lx = len(bx)\n ly = len(by)\n index = 0\n flag = 2\n k = -1\n if(lx!= ly):\n  index = max(lx,ly)\n  #print(index)\n  if((n+1)%2**(index) >= 2**(index-1)) :\n   k = 2**(index-1)\n  else :\n   k =( n+1)%(2**(index))\n  \n  if(lx<ly):\n   print(int((n+1)/2**index)*(2**(index-1)) + k) \n  else:\n   print(n+1 - (int((n+1)/2**index)*(2**(index-1)) + k))\n   \n else:\n  \n  for j in range(lx):\n   if(bx[j]!= by[j]):\n    index = lx-j\n    if(bx[j] == '0'):\n     flag = 0\n    else:\n     flag = 1\n    break\n  #  print(index)\n  if((n+1)%2**(index) >= 2**(index-1)) :\n   k = 2**(index-1)\n  else :\n   k =( n+1)%(2**(index))\n  if(flag == 2) :\n   print(0)\n  elif(flag == 1):\n   print(n+1 - (int((n+1)/2**index)*(2**(index-1)) + k))\n  else:\n   print(int((n+1)/2**index)*(2**(index-1)) + k) \n \n  \n# for 0\n# if((n+1)%2**(index) >= 2**(index-1)) : k = 2**(index-1)\n# else :k =( n+1)%(2**(index))\n#\n# (int(n+1)/2**index)*(2**(index-1) + k\n#\n  \n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13991