Multi test cases (about 100), every case occupies two lines.
The first line contains an integer n.
Then second line contain 2*n-1 integers $t_0, t_1, t_2, t_3, \ldots, t_{2*n-4}, t_{2*n-3}, t_{2*n-2}$ separated by exact one space.
The third line contains an integer m, indicates the number of query.
Next m lines will give queries
$\begin{matrix}
r_0 & c_0\\
r_1 & c_1\\
r_2 & c_2\\
\vdots & \vdots\\
r_{m-1} & c_{m-1}
\end{matrix}$
For $r_0, c_0$ the program will query the element of $M*M$ which locates in the $r_0^{th}$ row, $c_0^{th}$ column. For $r_i, c_i(0<i<m)$, assume that the answer of $i-1^{th}$ query is ANS, the program will query the element of $M*M$ which locates in $((r_i+ANS) \% n)^{th}$ row, $((c_i+ANS) \% n)^{th}$ column.
Please process to the end of file.
[Technical Specification]
$1 \leq n \leq 1000$
$0 \leq t_i \leq 100$
$0 \leq r_i, c_i \leq n-1$
$1 \leq m \leq 100000$