B. Mirror Grid
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a grid of size $$$N \times N$$$. Rows are numbered from $$$0$$$ to $$$N-1$$$ from top to bottom and columns are numbered from $$$0$$$ to $$$N-1$$$ from left to right. $$$(i, j)$$$ represents the cell on row $$$i$$$ and column $$$j$$$. $$$(0, 0)$$$ is therefore the cell at the top most left position.

Each cell in the grid is either empty or contains a block. There are $$$B$$$ ($$$1 \le B \le 20$$$) blocks in the grid. The blocks are placed in such a way that no two blocks share a side or a corner. Formally, no two cells $$$(a, b)$$$ and $$$(c, d)$$$ have blocks such that $$$|a-b| \leq 1 \And |c-d| \leq 1$$$. It is also guaranteed that there is no block on the cell $$$(0, 0)$$$. Your task is to find the positions of these blocks given the dimension of the grid.

You can do a query $$$420$$$ times to place mirrors on the grid and send a light ray starting from $$$(0, 0)$$$ in some direction. Note that mirrors placed for a particular query are removed before the next query. Mirrors can be placed on any cell, including $$$(0, 0)$$$ and cells containing blocks.

The query returns the number of mirrors the ray of light gets reflected from before hitting a block or going outside the grid. If a mirror is placed on the same cell as a block, light hits the block first and the mirror isn't counted in the return value. If a light ray hits the non reflecting side of a mirror it passes through to the next cell and nothing gets added. If the light starts going in a cycle $$$-1$$$ is returned.

A mirror is represented by a tuple of size $$$3$$$. The number of mirrors in a query can be no more than $$$4 \cdot N$$$ and no two mirrors can be placed in the same cell. The first $$$2$$$ integers in the tuple represent the row and column at which the mirror is placed respectively. The $$$3$$$rd integer represents the type of mirror. The mirrors are tilted such that light reflects perpendicularly on them and can be of $$$4$$$ types:

  • topLeft: The mirror is tilted like $$$/$$$ and the reflecting side is on top left. This is represented by $$$0$$$ in the code.
  • topRight: The mirror is tilted like $$$ \backslash $$$ and the reflecting side is on top right. This is represented by $$$1$$$ in the code.
  • bottomRight: The mirror is tilted like $$$/$$$ and the reflecting side is on bottom right. This is represented by $$$2$$$ in the code.
  • bottomLeft: The mirror is tilted like $$$\backslash$$$ and the reflecting side is on bottom left. This is represented by $$$3$$$ in the code.

You can choose the direction light travels in when starting from the cell $$$(0,0)$$$. These can be Down or Right represented by $$$0$$$ and $$$1$$$ in code respectively.

Please view the interaction format and sample explanation for more clarity.

Input

The input consists of a single integer $$$N(2 \le N \le 1000)$$$, representing the dimensions of the grid.

Interaction

Your program can ask queries using the format specified. It should first print $$$M$$$, the number of mirrors placed and $$$D$$$, the direction of the light. Then $$$M$$$ lines should follow, containing three integers each — the row $$$r_i$$$, column $$$c_i$$$ and type $$$t_i$$$ of mirror placed.

? M D

$$$r_1$$$ $$$c_1$$$ $$$t_1$$$

$$$r_2$$$ $$$c_2$$$ $$$t_2$$$

$$$\ldots$$$

$$$r_M$$$ $$$c_M$$$ $$$t_M$$$

When you want to give an answer you should first print the number of blocks $$$B$$$ determined, followed by the position of each block.

! B

$$$r_1$$$ $$$c_1$$$

$$$r_2$$$ $$$c_2$$$

$$$\ldots$$$

$$$r_B$$$ $$$c_B$$$

Note: In case of a wrong answer or invalid query, $$$-2$$$ will be returned by the judge. In such cases you must exit the program immediately.

Example
Input
4




1




0
Output

? 3 1
0 1 1
0 2 3
1 2 0

? 3 0
0 1 1
0 2 3
1 2 0

! 2
1 2
3 0
Note

The path of light for the first query can be seen in the image provided below. For the second query, light doesn't hit any mirrors and directly goes to the block at $$$(3, 0)$$$.