i want u to act as the most skilled competetive programmer, u take time to think and check if ur solution works and match up with the example tescase, u need to think thoroughly since u r in a contest.
use need to use this template, make sure u have lowercase rlly short variable names and NO COMMENTS (in the code, at all) and since ur using this template always use int and not long long, PLS REVALUATE UR CODE AND MAKE SURE IT MAKES SURE IT MATCHES EVERY SINGLE SAMPLE INPUT AND OUTPUT GIVEN, THINK MULTIPLE TIMES BEFORE GIVING UR FINAL ANSWER AS THIS IS A CONTEST:
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

E. Expected Power
time limit per test4 seconds
memory limit per test256 megabytes
You are given an array of n
 integers a1,a2,…,an
. You are also given an array p1,p2,…,pn
.

Let S
 denote the random multiset (i. e., it may contain equal elements) constructed as follows:

Initially, S
 is empty.
For each i
 from 1
 to n
, insert ai
 into S
 with probability pi104
. Note that each element is inserted independently.
Denote f(S)
 as the bitwise XOR of all elements of S
. Please calculate the expected value of (f(S))2
. Output the answer modulo 109+7
.

Formally, let M=109+7
. It can be shown that the answer can be expressed as an irreducible fraction pq
, where p
 and q
 are integers and q≢0(modM)
. Output the integer equal to p⋅q−1modM
. In other words, output such an integer x
 that 0≤x<M
 and x⋅q≡p(modM)
.

Input
Each test contains multiple test cases. The first line contains the number of test cases t
 (1≤t≤104
). The description of the test cases follows.

The first line of each test case contains a single integer n
 (1≤n≤2⋅105
).

The second line of each test case contains n
 integers a1,a2,…,an
 (1≤ai≤1023
).

The third line of each test case contains n
 integers p1,p2,…,pn
 (1≤pi≤104
).

It is guaranteed that the sum of n
 over all test cases does not exceed 2⋅105
.

Output
For each test case, output the expected value of (f(S))2
, modulo 109+7
.

Example
InputCopy
4
2
1 2
5000 5000
2
1 1
1000 2000
6
343 624 675 451 902 820
6536 5326 7648 2165 9430 5428
1
1
10000
OutputCopy
500000007
820000006
280120536
1
Note
In the first test case, a=[1,2]
 and each element is inserted into S
 with probability 12
, since p1=p2=5000
 and pi104=12
. Thus, there are 4
 outcomes for S
, each happening with the same probability of 14
:

S=∅
. In this case, f(S)=0
, (f(S))2=0
.
S={1}
. In this case, f(S)=1
, (f(S))2=1
.
S={2}
. In this case, f(S)=2
, (f(S))2=4
.
S={1,2}
. In this case, f(S)=1⊕2=3
, (f(S))2=9
.
Hence, the answer is 0⋅14+1⋅14+4⋅14+9⋅14=144=72≡500000007(mod109+7)
.

In the second test case, a=[1,1]
, a1
 is inserted into S
 with probability 0.1
, while a2
 is inserted into S
 with probability 0.2
. There are 3
 outcomes for S
:

S=∅
. In this case, f(S)=0
, (f(S))2=0
. This happens with probability (1−0.1)⋅(1−0.2)=0.72
.
S={1}
. In this case, f(S)=1
, (f(S))2=1
. This happens with probability (1−0.1)⋅0.2+0.1⋅(1−0.2)=0.26
.
S={1,1}
. In this case, f(S)=0
, (f(S))2=0
. This happens with probability 0.1⋅0.2=0.02
.
Hence, the answer is 0⋅0.72+1⋅0.26+0⋅0.02=0.26=26100≡820000006(mod109+7)
.