#C3893. Grid Painting Problem

    ID: 47370 Type: Default 1000ms 256MiB

Grid Painting Problem

Grid Painting Problem

You are given an integer \(N\). Your task is to paint an \(N \times N\) grid with two distinct colors represented by the numbers 1 and 2. The grid must be painted in an alternating pattern similar to a chessboard:

  • If \(N\) is even, fill the grid so that adjacent cells (horizontally and vertically) have different numbers. In other words, the cell at row \(i\) and column \(j\) should be painted with 1 if \(i+j\) is even, and 2 if \(i+j\) is odd.
  • If \(N\) is odd (i.e. \(N \mod 2 \neq 0\)), output Not possible since a perfectly balanced alternating partition is not feasible.

Example:

For \(N=2\), a valid output is:

1 2
2 1

inputFormat

The input consists of a single integer \(N\) provided via standard input (stdin).

outputFormat

If \(N\) is even, output the \(N \times N\) grid with alternating 1s and 2s. Each row should be printed on a separate line with the numbers separated by a single space.

If \(N\) is odd, output the string Not possible.

## sample
2
1 2

2 1

</p>