Različitost

시간 제한2초메모리 제한1024 MB

요약
주기가 각각 n과 m인 두 주기 수열의 첫 k개 항에 대해 a_i XOR b_i의 합을 구한다. k는 10^18까지 커질 수 있다.
난이도

어려움10점 중 8점

유형
수학, 정수론, 비트 연산, 구현
정답자
아직 제출이 없습니다

문제

Two infinite periodic sequences of integers, a_ia\_i and b_ib\_i, are given, defined by their periods of lengths nn and mm, respectively. This means that the natural numbers nn and mm are given, as well as the numbers a_1,a_2,…,a_na\_1, a\_2, \dots , a\_n and b_1,b_2,…,b_mb\_1, b\_2, \dots , b\_m, for which a_i=a_i+na\_i = a\_{i+n} and b_i=b_i+mb\_i = b\_{i+m} hold for every natural number ii.

Additionally, given a natural number kk, we define the "diversity" of these two sequences as the sum a_i⊕b_ia\_i \oplus b\_i for each i=1,2,…,ki = 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⊕3=(101)_2⊕(011)_2=(110)_2=65 \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 nn, mm, and kk (1≤n,m≤2⋅1051 ≤ n, m ≤ 2 \cdot 10^5, 1≤k≤10181 ≤ k ≤ 10^{18}), which are the numbers from the task description.

In the second line, there are nn integers a_1,…,a_na\_1, \dots , a\_n (0≤a_i≤10180 ≤ a\_i ≤ 10^{18}, i=1,2,…,ni = 1, 2, \dots , n).

In the third line, there are mm integers b_1,…,b_mb\_1, \dots , b\_m (0≤b_i≤10180 ≤ b\_i ≤ 10^{18}, i=1,2,…,mi = 1, 2, \dots , m).

출력

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

예제2

  1. 예제 1

    입력
    3 2 10
    1 6 4
    5 2
    
    예상 출력
    33
    
  2. 예제 2

    입력
    10 5 30
    5 16 2 10 7 2 4 20 5 12
    4 11 14 23 5
    
    예상 출력
    435