XCopy

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Today, at the end of the programming class, the teacher gave very difficult homework, so the children decided to cheat and copy it from one another. However, they have to work smart in order to not get caught cheating.

The class has N×MN \times M students, placed in N×MN \times M benches on NN rows and MM columns. Two children are considered neighbours if one sits in a bench adjacent to the left, the right, above or below the bench in which the other one sits. The homework consists of finding a certain non-negative integer. In order for them to not get caught cheating, all these integers must be different. Also, the children are very lazy, therefore they will barely modify their answers when copying them from their neighbours. More precisely, each child’s answer differs by exactly one bit in base 22 compared to any of his neighbours’ answers. For example 33 and 22 differ in exactly one bit, whereas 22 and 44 do not.

The children don’t want to raise suspicion, therefore they want the largest answer that any of them gave to be as small as possible. Given NN and MM, create a configuration of answers so that the teacher won’t find out the children cheated.

입력

The input consists of NN and MM on a single line, separated by a single space.

출력

The output consists of the optimal answers for the children. The output should have NN rows, each containing MM non-negative integers separated by a single space. These represent the answers for the children, according to where they sit in the class.

제한

  • 1N,M20001 ≤ N, M ≤ 2000

힌트

Within this section, a subscript after a number represents the base in which the number is written. For instance eight may be written as 8_10=1000_28\_{10} = 1000\_2.

One set of optimal answers for the students are given in the following table:

0101_2=5_100101\_2 = 5\_{10}0100_2=4_100100\_2 = 4\_{10}0110_2=6_100110\_2 = 6\_{10}
0001_2=1_100001\_2 = 1\_{10}0000_2=0_100000\_2 = 0\_{10}0010_2=2_100010\_2 = 2\_{10}
1001_2=9_101001\_2 = 9\_{10}1000_2=8_101000\_2 = 8\_{10}1010_2=10_101010\_2 = 10\_{10}

Observe that between any two adjacent benches the numbers differ with exactly one bit. The maximum value of the solution is 1010, which is the optimal answer. Clearly other solutions are optimal – such as the previous solution but flipped vertically or horizontally.

Another possible partial solution in which the maximum is 1515 is:

0110_20110\_20111_20111\_20101_20101\_2
1110_21110\_21111_21111\_21101_21101\_2
1010_21010\_21011_21011\_21001_21001\_2

This solution would be scored, according to the scoring formula, with 59.159.1\\% of the test case score.