Lone Knight

아직 제출이 없습니다시간 제한7초메모리 제한1024 MB

문제

In the game of chess, a knight moves as shown in the picture below; each move is one square horizontally and two squares vertically or two squares horizontally and one square vertically. A rook can move any number of squares horizontally or vertically, but not both in the same move. If a square can be reached by a rook in one move, that square is said to be attacked by the rook.

Consider an infinite chess board, with squares that can be indexed by integer coordinates. There is a white knight on the board on a square, and it wants to go to another square. However, there are also a number of black rooks on the board. The knight can make as many moves as it needs to get to its target square, but it cannot stop on a square that is attacked by or occupied by a rook. The rooks don't move.

Can the white knight reach its target square? You are to answer that question many times!

입력

The first line of input contains two integers nn and qq (1n,q1,0001 \leq n, q \leq 1\\,000), where nn is the number of black rooks and qq is the number of queries.

Each of the next nn lines contains two integers xx and yy. This indicates that there is a black rook at (x,y)(x,y). No two rooks share the same square.

Each of the next qq lines contains four integers x_sx\_s, y_sy\_s, x_tx\_t and y_ty\_t. This is a query, where the white knight starts at square (x_s,y_s)(x\_s,y\_s) and wants to move to square (x_t,y_t)(x\_t,y\_t).

All square coordinates in the input are no larger than 10910^9 in absolute value. It is guaranteed that in every query the knight's initial and target squares are not attacked by or occupied by any rook, and the target square is not the same as the initial square.

출력

For each query, output on a single line 1 if the knight can reach the target square, or 0 otherwise.