AT_abc444_g [ABC444G] Kyoen

Description

On a two-dimensional coordinate plane, there is a circle with center at point $ (\frac{A}{C}, \frac{B}{C}) $ and radius $ \frac{\sqrt{N}}{C} $ . Find the number, modulo $ 998244353 $ , of lattice points on the circumference of this circle. $ N $ is given in its prime factorization form as $ N=\prod_{i=1}^{M} P_i^{E_i} $ .

Input Format

The input is given from Standard Input in the following format: > $ A $ $ B $ $ C $ $ M $ $ P_1 $ $ E_1 $ $ P_2 $ $ E_2 $ $ \vdots $ $ P_M $ $ E_M $

Output Format

Output the answer.

Explanation/Hint

### Sample Explanation 1 As shown in the figure below, there are $ 12 $ lattice points on the circumference. ![Figure](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_abc444_g/8b9fd089bb963ee2f0a98c69d16adbf8ce25c379deebb2b2172a24bc55e132f6.png) ### Sample Explanation 2 As shown in the figure below, there are $ 4 $ lattice points on the circumference. ![Figure](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_abc444_g/ed5402da8eb6e7dfc0850d282b23d316a5637324ac217eab103cc9b0355bb72d.png) ### Sample Explanation 3 As shown in the figure below, there are $ 6 $ lattice points on the circumference. ![Figure](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_abc444_g/63443dcc5b581e87132214f436ef41c2325205f25bbdaace3c630e28782209d2.png) ### Sample Explanation 4 Find the number modulo $ 998244353 $ . ### Constraints - $ N \geq 1 $ - $ 2 \leq P_i \leq 100 $ - $ P_i $ are distinct primes. - $ 1 \leq E_i \leq 10^{18} $ - $ 1 \leq C \leq 50 $ - $ 0 \leq A,B \lt C $ - All input values are integers.