F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

sakura

Time 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
1 1 1 1 2 6 0 0 2 0 1 3 0 2 4 1 0 4 1 1 2 2 0 2
 

Sample Output
9216
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 07:16:01, Gzip enabled