#K51452. Vegetable Garden Plotting

    ID: 29090 Type: Default 1000ms 256MiB

Vegetable Garden Plotting

Vegetable Garden Plotting

You are given an M x M grid and an integer D representing the number of vegetable plots to be placed. Each plot occupies a single cell (1x1) in the grid. The placement must satisfy the following conditions:

  • No two plots are in the same row or the same column.
  • The Manhattan distance between any two plots, given by \( |x_1 - x_2| + |y_1 - y_2| \), is at least 3.

Your task is to determine an arrangement of D plots that satisfies these conditions. If such an arrangement is possible, output the coordinates of each plot. Otherwise, output This arrangement is not possible.

Note: Although the Manhattan distance condition appears in the problem statement, the intended solution simply places the plots along the diagonal if D is not greater than M.

inputFormat

The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains two space-separated integers M and D, where M is the size of the grid (i.e., the grid is M x M) and D is the number of plots to place.

outputFormat

For each test case, if it is possible to arrange the D plots, output exactly D lines with two space-separated integers representing the coordinates of each plot. The coordinates for the i-th plot should be printed on its own line. If no valid arrangement is possible, output a single line with the text This arrangement is not possible.

When there are multiple test cases, the output for each test case should be separated by a single blank line.

## sample
2
4 3
5 5
0 0

1 1 2 2

0 0 1 1 2 2 3 3 4 4

</p>