Rooks
시간 제한2초메모리 제한1024 MB
평면 위에 두 사람이 룩을 놓고, 같은 행이나 열에서 사이에 다른 룩 없이 상대 룩의 공격을 받는 룩을 가린다.
문제
Prof. Pang plays chess against his rival Prof. Shou. They are the only two players in the game. The chessboard is very large and can be viewed as a 2D plane. Prof. Pang placed rooks and Prof. Shou placed rooks. Each rook is a point with integer coordinates on the chessboard. One rook is attacked by another rook if they satisfy all of the following conditions:
- They are placed by different players.
- They have the same -coordinate or -coordinate.
- There is no other rook on the line segment between them.
Help Prof. Pang and Prof. Shou to decide which rooks are attacked.
입력
The first line contains two integers () separated by a single space denoting the number of rooks placed by Prof. Pang and the number of rooks placed by Prof. Shou.
The -th () line of the next lines contains two integers () separated by a single space denoting the location of the -th rook placed by Prof. Pang.
The -th () line of the next lines contains two integers () separated by a single space denoting the location of the -th rook placed by Prof. Shou.
It is guaranteed that the rooks placed by the players are distinct (i.e., no two rooks can have the same location).
출력
Output a string with length on the first line. The -th () character should be if the -th rook placed by Prof. Pang is attacked and otherwise.
Output a string with length on the second line. The -th () character should be if the -th rook placed by Prof. Shou is attacked and otherwise.