#K63292. Paint the Room

    ID: 31721 Type: Default 1000ms 256MiB

Paint the Room

Paint the Room

You are given a room represented as an \(n \times m\) grid. Your task is to paint the room such that each row contains exactly one cell painted in blue, with the constraint that no two adjacent cells in the same row can both be blue. In other words, every row must have exactly one blue cell and these blue cells must not be adjacent horizontally.

If it is possible to paint the room following these rules, output "YES" followed by the coordinates (row, column) of the blue-painted cells for each row. Otherwise, output "NO".

Note: The cell coordinates are 1-indexed. The condition requiring no adjacent blue cells is automatically satisfied if each row has exactly one blue cell and they are placed in distinct columns.

inputFormat

The first line contains an integer \(T\) --- the number of test cases. Each of the following \(T\) lines contains two space-separated integers \(n\) and \(m\), where \(n\) is the number of rows and \(m\) is the number of columns of the grid.

outputFormat

For each test case, if a valid painting exists, output "YES" on the first line, followed by \(n\) lines each containing two integers \(r\) and \(c\) --- the coordinates of the blue-painted cell in that row. If it is not possible, output "NO" on a single line.

## sample
1
3 3
YES

1 1 2 2 3 3

</p>