Description
Given three sequences a=[a1,a2,...an], b=[b1,b2,...bn] and c=[c1,c2,...cn] each containing n non-negative integers. You need to compute the value of $\displaystyle\sum_{p=1}^n\sum_{k=1}^{+\infty }d_{p,k}*c_{p}^k$.
And the sequence d=[dp,1,dp,2...dp,n] is calculated by the following rule:
For every integer p (1⩽p⩽n), every integer k (1⩽k⩽n), dp,k=k=i⊕j∑ai∗bj, (the range of i, j is 1≤i≤pn, 1≤j≤pn). Wherein,the notation ⊕ represents an operation in which the value of each bit of K in the ternary representation is equal to the greatest common divisor of the corresponding bit of I, J in the ternary representation. Formally speaking, decimal numbers (K)10, (I)10, (J)10 can be respectively represented as three ternary numbers (km−1km−2...k0)3, (im−1im−2...i0)3, (jm−1jm−2...j0)3 . For every integer t in (1⩽t⩽m), kt=gcd(it,jt), where gcd(x,y) is the greatest common divisor of x and y, specially, we define that gcd(x,0)=gcd(0,x)=x. For example, if x=(5)10=(012)3,y=(10)10=(101)3, then k=(111)3=(13)10
Output the answer mod 109+7.
There is only one test case for this question.
The first line contains an integer n (n≤2∗105) — length of the sequence a,b,c.
The second line contains n integers a1,a2,…,an(1≤ai≤109).
The third line contains n integers b1,b2,…,bn(1≤bi≤109).
The fourth line contains n integers c1,c2,…,cn(1≤ci≤109).
Output
Print an integer, which is the answer modulo 109+7
Samples
4
2 3 4 5
1 2 3 4
9 8 7 6
1643486