#K15831. Alternating Squares Game
Alternating Squares Game
Alternating Squares Game
Given an integer \( n \), generate an \( n \times n \) grid where the numbers 1 and 2 alternate. The top-left cell always contains 1. The pattern is constructed such that for any cell at coordinates \( (i, j) \), if \( i+j \) is even then the cell contains 1; otherwise, it contains 2.
This creates a pattern similar to a chessboard. The grid should be printed row by row, with each number separated by a single space.
Constraints: \(1 \leq n \leq 1000\).
inputFormat
The input consists of a single integer, \( n \), representing the size of the grid. This is provided via standard input (stdin).
outputFormat
Output the generated \( n \times n \) grid. Each row must be printed on a new line, and the numbers in each row should be separated by a single space. The output should be written to standard output (stdout).
## sample3
1 2 1
2 1 2
1 2 1
</p>