Under construction

Still being built. Things may change

Dave's Worry

Time limit2sMemory limit1024 MB

Summary
Assign one of 5 species to each cell of an N by M grid so that no two side-adjacent cells match and each interior cell touches all four other species.
Level

Medium7 of 10

Topics
Matrix, Implementation, Math
Solved
No attempts yet

Problem

Dave received a fish farm from Auto with the help of you all at last year's year-end contest. Over the past year he raised fish diligently and earned a lot of money. With this money, Dave greatly expanded the fish farm!

The expanded farm is a grid of square cells, N×MN \times M in size.

[Figure 1] The newly expanded fish farm of Dave

Dave plans to raise fish of 5 species on this farm. Dave cares a great deal about the privacy of his fish, so each cell holds exactly one fish. When choosing the species for each cell, the following rules must be followed.

  • Fish of the same species cannot be raised in two cells that are adjacent horizontally or vertically. Otherwise the fish would breed uncontrollably.
  • A fish in a cell adjacent to all 4 cells horizontally and vertically (that is, a cell not on an edge or corner of the farm) must be adjacent to fish of all 4 species other than its own.

Dave is trying to decide which fish to raise in each cell so that the rules are followed. Find one arrangement of fish that satisfies the rules and help Dave.

Input

The first line contains two integers NN and MM, separated by a space, giving the size of the fish farm.

Output

Print NN lines, each containing MM integers separated by spaces. The jj-th number on the ii-th line is an integer from 11 to 55 that denotes the species of fish raised in the cell in row ii from the top and column jj from the left.

Constraints

  • 3≤N,M≤10003 \leq N,M \leq 1000

Examples1

  1. Example 1

    Input
    3 3
    
    Expected output
    1 2 1
    5 1 4
    1 3 5