The floor of Gholam's bedroom is tiled with white and yellow tiles. When he gets bored he stands on one of the tiles and walks along the row he is standing on. He first picks a number of steps n and then moves one tile at a time in the direction he faces. When he reaches a wall he turns around and keeps walking the other way. He stops once he has taken n steps. Turning around at a wall does not count as a step. While he walks he counts how many times he steps on a yellow tile.
For example, write Y for a yellow tile and W for a white one, and take the row Y W W Y W Y. If Gholam starts on tile 3 facing right and decides to take 7 steps, he ends up on tile 2. Along the way he steps on a yellow tile three times.
The input holds several test cases. The first line contains the number of test cases T. Each test case takes two lines.
The first line contains two integers m (3≤m≤100) and n (1≤n≤1000). m is the number of tiles in the row and n is the number of steps Gholam takes.
The second line contains m integers describing the tiles, separated by spaces.
a1 a2 ... am
Each ai is 0, 1, 2, or 3. If ai=0, tile i is yellow, and if ai>0, tile i is white. If ai=2, Gholam starts on tile i facing right, and if ai=3, he starts on tile i facing left. Exactly one of the numbers is 2 or 3. Gholam always starts on a white tile.
For each test case, print on its own line the number of times Gholam steps on a yellow tile.