#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int n;
int main()
{
cin>>n;
int now = 1;
int x=1,y=1,flag=1;//flag=0向左下,1向右上
while(now<=(n*n+1)/2+1){
a[x][y] = now;
a[n-x+1][n-y+1] = n*n-now+1;
now++;
if(flag==1 && x==1){
y++;
flag = 0;
}
else if(flag==0 && y==1){
x++;
flag = 1;
}
else{
if(flag==0){
x++;
y--;
}
else{
x--;
y++;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cout<<a[i][j]<<' ';
}
cout<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int maxx[105],minn[105],n,m;
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=m;i++){
minn[i] = 999999999;
for(int j=1;j<=n;j++){
maxx[i] = max(maxx[i],a[j][i]);
minn[i] = min(minn[i],a[j][i]);
}
}
for(int i=1;i<=m;i++){
cout<<maxx[i]<<' ';
}
cout<<endl;
for(int i=1;i<=m;i++){
cout<<minn[i]<<' ';
}
return 0;
}