Chef is playing with an expression which consists of integer operands and the following binary
Bitwise operators -  AND, OR and XOR. He is trying to figure out that what could be the Maximum possible answer of the expression, given that he can perform the operation in any order i.e not necessarily follow the rule of Precedence of operators while evaluating the expression.
After some time of consistent work Chef starts feeling exhausted and wants you to automate this process for him. Can you help him out?
The expression has Bitwise operators in symbol format:
- &  stands for AND 
- |   stands for OR
- ^   stands for XOR
NOTE : It is guaranteed that the expression will always be valid, also each OPERATOR will always be preceded and succeeded by an OPERAND.

-----Input:-----
- The first line of input contains a single integer $T$ denoting the number of test cases.
- The only line of input for each test case is a $string$ which is the Chef's expression to evaluate.

-----Output:-----
For each test case print a single integer i.e the maximum possible value of Chef's expression.

-----Constraints-----
- $1 \leq T \leq 100$.
- The number of OPERATORS in the expression will be atleast 1 and atmost 10.
- Each OPERAND may range from 0 to $10^9$.

-----Subtasks-----
- 10 points : The number of OPERATORS in the expression will be atmost 5.
- 20 points : The number of OPERATORS in the expression will be atmost 8.
- 70 points : Original constraints.

-----Sample Input:-----
2
3^40|10^2

92^95|56&2&3

-----Sample Output:-----
43

95

-----EXPLANATION:-----CASE 2 :
- If we first compute (56 & 2), the expression becomes 92^95|0&3, since (56 & 2) yields $0$.
- Now on computing (95 | 0), the expression becomes 92^95&3.
- Further on computing (95 & 3), the expression becomes 92^3.
- Finally (92 ^ 3) yields 95, which is the maximum value of the expression.

```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 = "def value(a, b, c):\r\n    if(c == '&'):\r\n        return a&b\r\n    elif(c == '^'):\r\n        return a^b\r\n    elif(c == '|'):\r\n        return a|b\r\n\r\ndef break_rules(n, operator):\r\n    if(len(n) == 1):\r\n        return n\r\n    elif(len(n) == 2):\r\n        return [value(n[0], n[1], operator[0])]\r\n    else:\r\n        cont_ans = []\r\n        for i in range(1,len(n)):\r\n            l1 = n[:i]\r\n            l2 = n[i:]\r\n            o1 = operator[:i - 1]\r\n            o2 = operator[i:]\r\n            l1_ans = break_rules(l1, o1)\r\n            l2_ans = break_rules(l2, o2)\r\n            for k in l1_ans:\r\n                for j in l2_ans:\r\n                    cont_ans.append(value(k, j, operator[i - 1]))\r\n    return cont_ans\r\n\r\nt = int(input())\r\nwhile t > 0 :\r\n    operator = []\r\n    num = []\r\n    exp = input()\r\n    temp = ''\r\n    for i in range(len(exp)):\r\n        if(ord(exp[i]) > 47 and ord(exp[i]) < 58):\r\n            temp = temp + exp[i]\r\n        else:\r\n            num.append(int(temp))\r\n            temp = ''\r\n            operator.append(exp[i])\r\n        if(i == len(exp) - 1):\r\n            num.append(int(temp))\r\n    t -= 1\r\n    \r\n    print(max(break_rules(num, operator)))"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13591