|
||||||||||
sakuraTime Limit: 4000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 560 Accepted Submission(s): 60 Problem Description There is an infinite 3D value grid space $a_{i,j,k}$. Initially, for $ \forall i,j,k \ a_{i,j,k}$ = 1. First, we change the value of $m$ grids. In the $i-th$ operation, we change the value of $a_{n, x_i, y_i}$ from 1 to $v_i$. Then the grid in the space will change every second. The value of the grid $a_{i,j,k}$ will change to $a_{i+1,j+p,k} ^ {t1} \times a_{i+1,j,k+q} ^ {t2} \times a_{i+1,j,k} \times a_{i,j,k}$ for every second. We want to know $a_{0,0,0} mod \ 998244353$ after $n$ seconds. Input There are several test cases in the input file. In the each test case, the first line contains six integers $t1,t2,p,q,n,m (1 \leq t1,t2,p,q,n \leq 10^9, 1 \leq m \leq 10 ^ 5)$. The $i-th$ line in the next $m$ lines contains three integers $x_i, y_i, v_i (0 \leq x_i,y_i \leq 10^9, \ 1 \leq v_i \leq 10^9)$ It is guaranteed that $\sum m \leq 2*10^5$ and for $ \forall i,j (\ i \neq j) ; \ x_i \neq x_j \ or \ y_i \neq y_j$ in each test case. Output For each test case, print a single line containing an integer, denoting the value of $a_{0,0,0} \ mod \ 998244353$ after $n$ seconds. Sample Input
Sample Output
Source | ||||||||||
|