There is an old drawing program called turtle graphics. The program is given a series of $L$ lines and it will draw them on an $X$ by $Y$ matrix. A line consists of a series of $n$ points, and the program will draw a straight line between two consecutive points. For simplicity we assume that the each segment of a line is either vertical, horizontal, or $45^{\circ}$ diagonal.
The input is as follow. The first line has $L$, $X$, and $Y$. All of them are between 1 and 100. Each of the next $L$ lines starts with $n$, the number of points in that line, and the next $n$ pairs of coordinates indicate the position of the points in the that line. Note that $n$ is positive and could be very large so you cannot store the coordinates in an array. If you are given a point that is not in the grids, or does not form a vertical, horizontal, or $45^{\circ}$ diagonal line with the previous point, report the line number and point number and stops the program.
If the input is correct, then the output has $X$ lines, each of them has $Y$ numbers. You should output a $1$ if that cell is drawn, $0$ otherwise. If the input is incorrect report the line number and point number of the point that is causing the problem. Both line number and point number start from $1$.
Technical Specification and constraints
10 pt. $L$ is $1$ and the line is a valid horizontal line, i.e, $n$ is $2$.
30 pt. $L$ is $1$ and the lines are only horizontal and vertical, $n$ is between $1$ and $10$, and the input is always correct.
40 pt. $L$ is between $1$ and $100$ and the lines could be vertical, horizontal, or $45^{\circ}$ diagonal, $n$ is between $1$ and $10$, and the input is always correct.
10 pt. $L$ is between $1$ and $100$ and the lines could be vertical, horizontal, or $45^{\circ}$ diagonal, $n$ is between $1$ and $10$, and input could be incorrect.
10 pt. $L$ is between $1$ and $100$ and the lines could be vertical, horizontal, or $45^{\circ}$ diagonal, $n$ could be very large so you CANNOT store the points in an array, and input could be incorrect.