Time limit: 2 seconds Memory limit: 256 MB A thief with skill needs the skill of…
- User
Time limit: 2 seconds Memory limit: 256 MB A thief with skill needs the skill of climbing and jungular play in stealing; Because after finding the store's cameras and entering it, he realized that the marbles are on the top floor. He was on the first floor of the store and should go to the last floor n nth to go Each floor has two windows. One on the right side of the floor and one on the left side of the floor (assume each floor is a horizontal line segment with windows on its two edges). If the thief on the floor k be k, it can only belong to the floor k + 1 go k+1 If, for example, he is in the class k k, there are two ways to go to the next floor:
- From the window on the right side of the floor k I got out and went to the floor through the window on the right k
1 Enter k+1.
- From the window on the left side of the floor k I got out and through the window on the left, to the floor k
1 Enter k+1.
Unfortunately, there are police in some floors. There is a maximum of one policeman per floor. There is no police on the first and last floor. Because each policeman is tired (their working hours are long!), he can only watch one of the windows of the floor he is in; That is, the thief cannot enter that floor through that window, and at the same time, he cannot leave the window on that floor and go to the upper floor through the window guarded by the police. That is, if, for example, a policeman in the k k and be careful of the right window and ask the thief from the floor k
1 k−1th to the floor k + 1 k+1 must go from the left window of the floor k
1 The k−1th exited and went to the floor through the left window k Enter the kth. Then you have to go again from the window on the left side of the floor k I used k and through the left window, to the floor k + 1 Enter k+1. Pay attention that if there is no policeman on a floor, you can leave from both windows and you can enter from both windows. The thief knows the location of the policemen and the window each of them is guarding. He gives you this information and wants you to tell him if he can go to the top floor or not.
input In each entry, there are a number of tests that your program must answer in order.
In the first line of each entry, a number t t stands for the number of tests to be answered in this entry. Then in each test:
In the first line of each test, two numbers n n and k k represents the number of classes and the number of policemen in this test. in k k next line, in line i, first a i a i which represents the class of police presence i I am, it has come. Then there is a number that represents the window where the police i i takes care that this number is either 0 or 1:
0: means the police i i is looking after the right window.
1: It means that the police i i looks after the left window.
- Assistant