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.