Once a puzzle has been gifted to Taja, and she still has no idea how to solve it.
The puzzle is a grid $n \times n$, with each row and each column containing exactly one separator, which is diagonal segment which starts in upper left corner and ends at lower right corner. Puzzle has a launch button, which launches the balls at integer time moments from the tubes, which are positioned at the boundary of the grid. Per one moment a ball moves to an adjacent cell. When a ball collides a separator it changes direction by $90^\circ$. A ball disappears if it crosses border line.
To solve a puzzle, one needs to rotate some separators $90^\circ$ around their centers, in such a way that no two balls will ever collide inside the grid.
Two balls collide if:


In this problem you are to find any solution of this puzzle.
First line of input contains single integer $n$ ($1 \leq n \leq 500$) --- grid size.
Second line contains $n$ integers ($1 \leq c_i \leq n$) --- column number of $i$th separator, which has $i$ as a row number. All column numbers are different.
Third line conatins single integer $m$ ($1 \leq m \leq 10^4$) --- number of balls.
Each of the following $m$ lines contains $3$ integers $x_i$, $y_i$, $t_i$ ($0 \leq t_i \leq 10^8$), describing moments of balls' launches --- at the moment $t_i$ a ball will appear at $(x_i, y_i)$ cell, which shares common side with the boundary of the grid. Moments are given in non-decreasing order of $t_i$. Coordinates ($x_i, y_i$) can be at one of the four following areas:
It is guaranteed that solution always exists.
Output should contain single line of $0$ and $1$. $i$th symbol is $0$, if $i$th separator doesn't require rotation, $1$ --- otherwise.
Below are shown sample positions of the balls along the time.
| 0 | ![]() | 1 | ![]() | 2 | ![]() | 3 | ![]() |
| 4 | ![]() | 5 | ![]() | 6 | ![]() | 7 | ![]() |