Younghee and Dongsu play a coin toss game. The game runs for K rounds under these rules.
Let M be Younghee's score and N be Dongsu's score at the moment the game stops. Picking any two integers M and N between 0 and K does not give a pair that a game can actually produce. For K=2, the nine pairs split like this.
| M | N | Can be the scores of Younghee and Dongsu |
|---|---|---|
| 0 | 0 | Possible |
| 0 | 1 | Possible |
| 0 | 2 | Impossible |
| 1 | 0 | Possible |
| 1 | 1 | Possible |
| 1 | 2 | Possible |
| 2 | 0 | Possible |
| 2 | 1 | Possible |
| 2 | 2 | Possible |
Here is why (M,N)=(0,2) is impossible. Dongsu needs a head in both rounds to reach 2 points, so he already holds 1 point when the second round starts. Younghee has to toss a tail to stay at 0 points, and at that moment she has no tosses left, so she can never pass Dongsu. Rule 3 stops the game at 0 and 1, and Dongsu never tosses his second coin.
Given M and N, decide whether the two numbers can be Younghee's and Dongsu's scores once the game has ended.
The first line has the number of rounds K (1≤K≤1000).
The second line has the number of queries C (1≤C≤100000).
Each of the next C lines has two integers M and N separated by a space (0≤M,N≤K).
Print C lines. On the i-th line print 1 if the M and N of the i-th query can be the scores of Younghee and Dongsu once the game has ended, and 0 otherwise.