Given two sequences {`A`_{0}, `A`_{1}, ..., `A`_{N-1}} and {`B`_{0}, `B`_{1}, ..., `B`_{M-1}}. Defined a function called `G`(`L`, `R`, `S`) on sequence `S`, where `G`(`L`, `R`, `S`) = GCD(`S`` _{i}`) (

You task is to calculate the length of LCGCDS and the number of LCGCDS of two given sequences `A` and `B`.

Note: Two LCGCDS are considered different if one of the two integer (`i`, `j`) is different.

There are multiple test cases. Each case begin with a line contains two integers `N` and `M` (1 ≤ `N`, `M` ≤ 100000). The second line contains `N` integers, `A`_{0}, `A`_{1}, ..., `A`_{N-1} (1 ≤ `A`_{i} ≤ 10^{9}). The third line contains `M` integers, `B`_{0}, `B`_{1}, ..., `B`_{M-1} (1 ≤ `B`_{i} ≤ 10^{9}).

One line for each case, you should output the length of LCGCDS and the number of LCGCDS, seprated by one space. If you can't find any LCGCDS, please just output "0 0" (without quotes).

提交代码