Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded from the exhibition independently randomly.
The beauty of the resulting exhibition is the bitwise XOR of the beauties of all displayed paintings. If no paintings are displayed, the XOR is $0$.
Monisha wants to find out how beautiful her exhibition is going to be. Help her compute the expected value of the beauty of the exhibition.

-----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 line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $b_1, b_2, \ldots, b_N$.
- The third line contains $N$ space-separated real numbers $p_1, p_2, \ldots, p_N$. Each of these numbers is given with at most five digits after the decimal point.

-----Output-----
For each test case, print a single line containing one real number — the expected beauty of the exhibition. Your answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$.

-----Constraints-----
- $1 \le N \le 10^5$
- $0 \le b_i \le 10^9$ for each valid $i$
- $0 \le p_i \le 1$ for each valid $i$
- the sum of $N$ over all test cases does not exceed $4 \cdot 10^5$

-----Example Input-----
2
3
5 6 2
1.0 0.0 0.5
4
2 2 2 2
0.5 0.5 0.5 0.5

-----Example Output-----
6.000000000000000
1.000000000000000

-----Explanation-----
Example case 1: The first painting must be displayed at the exhibition, the second one must be excluded. If the third painting is displayed (with probability $0.5$), the beauty is $5 \oplus 2 = 7$; if it is excluded (with probability $0.5$), the beauty is $5$. The expected beauty is $0.5 \cdot 5 + 0.5 \cdot 7 = 6$.
Example case 2: If there is an odd number of paintings at the exhibition, the beauty is $2$; this has a probability of $0.5$. If there is an even number of paintings, the beauty is $0$ (with probability $0.5$), so the expected beauty is $0.5 \cdot 0 + 0.5 \cdot 2 = 1$.

```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 = 'from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import *\nfrom itertools import *\nimport functools\nimport sys\nfrom math import *\nfrom decimal import *\nfrom copy import *\ngetcontext().prec = 30\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 10**9+7\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n  return False\n if n == 2: \n  return True \n if not n & 1: \n  return False\n for x in range(3, int(n**0.5) + 1, 2):\n  if n % x == 0:\n   return False\n return True\n\ndef mhd(a,b):\n return abs(a[0]-b[0])+abs(b[1]-a[1])\n\ndef numIN(x = " "):\n return(map(int,sys.stdin.readline().strip().split(x)))\n\ndef charIN(x= \' \'):\n return(sys.stdin.readline().strip().split(x))\n\ndef arrIN():\n return list(numIN())\n\ndef dis(x,y):\n a = y[0]-x[0]\n b = x[1]-y[1]\n return (a*a+b*b)**0.5\n\ndef lgcd(a):\n g = a[0]\n for i in range(1,len(a)):\n  g = math.gcd(g,a[i])\n return g\n\ndef ms(a):\n msf = -MAX\n meh = 0\n st = en = be = 0\n for i in range(len(a)):\n  meh+=a[i]\n  if msf<meh:\n   msf = meh\n   st = be\n   en = i\n  if meh<0:\n   meh = 0\n   be = i+1\n return msf,st,en\n\ndef flush():\n return sys.stdout.flush()\n\n\'\'\'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\xa0\xa0\xa0\xa0\'\'\'\n\nfor _ in range(int(input())):\n n = int(input())\n a = arrIN()\n p = list(map(float,input().split()))\n dp = [0]*32\n for i in range(32):\n  for j in range(n):\n   if ((a[j]) & (1<<i)):\n    dp[i] = (1-p[j])*dp[i]+(1-dp[i])*p[j]\n ans = 0\n for i in range(32):\n  ans+=dp[i]*(1<<i)\n print(ans)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 184889