P3164 [CQOI2014] Harmonious Matrix

Description

We call a matrix composed of $0$ and $1$ harmonious if and only if every element has an even number of adjacent $1$'s. The neighbors of an element include the element itself and its four neighbors above, below, left, and right (if they exist). Given the number of rows and columns of the matrix, compute and output a harmonious matrix. Note: the all-zero matrix is not allowed.

Input Format

The input consists of one line containing two space-separated integers $m$ and $n$, denoting the number of rows and columns of the matrix.

Output Format

Output $m$ lines, each containing $n$ space-separated integers ($0$ or $1$), forming the required matrix. The testdata guarantees that a solution exists.

Explanation/Hint

Constraints $1\le n,m\le 40$. Thanks to @miaomiao for providing the SPJ. Translated by ChatGPT 5