时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
You are given two arrays

and

, which has
infinite length.
The first

elements of

is

. If

, there is always

.
The first

elements of

is

. If

, there is always

.
It is guaranteed that
%3D1_%7B%7D)
(gcd: the greatest common divisor).
You are given an integer

, you should find how many

satisfy

.
输入描述:
The first line of the input contains three integer
,
, meaning as shown above.
The second line contains
integers
.
The third line contains
integers
.
输出描述:
The output contains an integer, representing the answer.
示例2
输入
复制
5 6 1919810
1 2 3 4 5
1 1 4 5 1 4