Makomuno has N servers and M databases. All databases are synchronized among all servers and each database has a ordered list denotes the priority of servers to access. This list is guaranteed to be a valid permutation of all servers.
Every time someone wants to execute queries on a certain database, he will send a request to the first server in the list. If it's dead, he will simply turn to the next one. Otherwise a working copy of the database is found, and this copy is called active.
Now, given N and M, Makomuno wants to find a permutation for each database which could assure that all servers are load-balanced. Moreover, Makomuno hopes the system will be load-balanced even if
exactly one server is broken.
Note that if we call the number of active copies on i-th server A
i, then load-balanced means max∣A
i - A
j∣≤1 for any i and j in non broken servers set. We won't consider broken servers in this case.
The input contains several test cases, terminated by EOF.
Each test case has one line containing two integer N ( 2≤N≤100) and M ( 1≤M≤100).
For each case output M lines, the i-th line contains a permutation of all servers, indicating the expected order. Servers are numbered from 1 to n.