CF1739A.Immobile Knight

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Immobile Knight

There is a chess board of size n×mn \times m. The rows are numbered from 11 to nn, the columns are numbered from 11 to mm.

Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction:

Find any isolated cell on the board. If there are no such cells, print any cell on the board.

Input

The first line contains a single integer tt (1t641 \le t \le 64) — the number of testcases.

The only line of each testcase contains two integers nn and mm (1n,m81 \le n, m \le 8) — the number of rows and columns of the board.

Output

For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.

Note

In the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.

In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.

In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle.

Samples

3
1 7
8 8
3 3
1 7
7 2
2 2

在线编程 IDE

建议全屏模式获得最佳体验