Consider four integers , , , and , such that . Let's put them in the corners of a square in some order and draw a loop . Depending on the arrangement of the integers, we can get different loop shapes, but some arrangements produce the same shape:
There are three possible loop shapes we can get:
Now consider an matrix filled with distinct integers from to , inclusive. Each square in this matrix can be seen as a square with integers in its corners. Let's build a loop for each of these squares like we did before:
Your task is to perform the inverse operation. You are given the shape types for all loops, and you need to build an matrix filled with distinct integers from to , inclusive, that produces these shapes.
输入格式
The first line contains two integers and ().
Each of the next lines contains a string of characters without spaces. Each character is a digit from to , denoting the type of the shape of the corresponding loop.
输出格式
Print an matrix filled with distinct integers from to , inclusive, that produces the shapes of the loops in the input.
It can be shown that such a matrix always exists. If there are multiple answers, print any of them.