#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int sq[n][n];
for (int i=0; i<n; i++)//заподнение массива с заданным свойством
{
int a=i+1;
for (int j=0; j<n; j++)
{
sq[i][j]=a;
a++;
if (a>n) a=1;
}
}
for (int i=0; i<n; i++)//вывод
{
for (int j=0; j<n; j++)
cout<<sq[i][j]<<' ';
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CglpbnQgbjsKCWNpbj4+bjsKCWludCBzcVtuXVtuXTsKCWZvciAoaW50IGk9MDsgaTxuOyBpKyspLy/Qt9Cw0L/QvtC00L3QtdC90LjQtSDQvNCw0YHRgdC40LLQsCDRgSDQt9Cw0LTQsNC90L3Ri9C8INGB0LLQvtC50YHRgtCy0L7QvAoJewoJCWludCBhPWkrMTsKCQlmb3IgKGludCBqPTA7IGo8bjsgaisrKQoJCXsKCQkJc3FbaV1bal09YTsKCQkJYSsrOwoJCQlpZiAoYT5uKSBhPTE7CgkJfQoJfQoJZm9yIChpbnQgaT0wOyBpPG47IGkrKykvL9Cy0YvQstC+0LQKCXsKCQlmb3IgKGludCBqPTA7IGo8bjsgaisrKQoJICAgICAgICBjb3V0PDxzcVtpXVtqXTw8JyAnOwoJICAgIGNvdXQ8PGVuZGw7Cgl9ICAgIAoJcmV0dXJuIDA7Cn0=