시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB358825.000%

문제

Two infinite periodic sequences of integers, $a_i$ and $b_i$, are given, defined by their periods of lengths $n$ and $m$, respectively. This means that the natural numbers $n$ and $m$ are given, as well as the numbers $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$, for which $a_i = a_{i+n}$ and $b_i = b_{i+m}$ hold for every natural number $i$.

Additionally, given a natural number $k$, we define the "diversity" of these two sequences as the sum $a_i \oplus b_i$ for each $i = 1, 2, \dots , k$. (Here, $\oplus$ denotes the bitwise exclusive OR operation, which produces ones in the positions where the binary digits of the two numbers differ. For example, $5 \oplus 3 = (101)_2 \oplus (011)_2 = (110)_2 = 6$.)

Your task is to calculate the diversity of the given sequences.

입력

In the first line, there are $n$, $m$, and $k$ ($1 ≤ n, m ≤ 2 \cdot 10^5$, $1 ≤ k ≤ 10^{18}$), which are the numbers from the task description.

In the second line, there are $n$ integers $a_1, \dots , a_n$ ($0 ≤ a_i ≤ 10^{18}$, $i = 1, 2, \dots , n$).

In the third line, there are $m$ integers $b_1, \dots , b_m$ ($0 ≤ b_i ≤ 10^{18}$, $i = 1, 2, \dots , m$).

출력

Because the answer can be very large, output the remainder of the answer when divided by $10^9 + 7$ in a single line.

서브태스크

번호배점제한
125

$k ≤ 2 \cdot 10^5$

213

$n = m$

39

$n = 1$

443

No additional constraints.

예제 입력 1

3 2 10
1 6 4
5 2

예제 출력 1

33

예제 입력 2

10 5 30
5 16 2 10 7 2 4 20 5 12
4 11 14 23 5

예제 출력 2

435

채점 및 기타 정보

  • 예제는 채점하지 않는다.