A sequence of integers a_i is defined as follows:
where the sequences b_j and c_j (1 \leq j \leq k) consist of given integer numbers. Your task is to compute a_n for a given and output the result modulo 10^9.
The first line contains the integer (1 \leq t \leq 10^4), the number of test cases.
Each test case consists of four lines:
The first line contains a single integer (1 \leq k \leq 10) — the length of the sequences and .
The second line contains integers b_1, b_2, \ldots, b_k (0 \leq b_j \leq 10^9), the initial values of the sequence.
The third line contains integers c_1, c_2, \ldots, c_k (0 \leq c_j \leq 10^9), the coefficients of the recurrence.
The fourth line contains a single integer (1 \leq n \leq 10^9) — the required position in the sequence.
For each test case, print a single integer: the value of a_n modulo 10^9.
Örnek
2
3
1 2 3
2 1 3
4
3
1 2 3
2 1 3
611
45Örnek 1