#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
int t = 1;
cin>>n;
int** arr = new int*[n+1];
for(int i = 0; i<n+1;i++){
arr[i] = new int[n+1];
}
for(int i = 0;i<n;i++){
for(int j = 0;j<n;j++){
arr[i][j] = 0;
}
}
int head = 0;
int pos = 1;
for(int i =0;i<n;i++){
int y = i;
if(pos == 1){
for(int j = 0;j<n && y>=0;){
arr[y--][j++] = t++;
}
pos = -1;
}else{
for(int j = 0;j<n && y>=0;){
arr[j++][y--] = t++;
}
pos = 1;
}
}
for(int i =1;i<n;i++){
int y = i;
if(pos == -1){
for(int j = n-1;j>0 && y<n;){
arr[y++][j--] = t++;
}
pos = 1;
}else{
for(int j = n-1;j>0 && y<n;){
arr[j--][y++] = t++;
}
pos = -1;
}
}
for(int i = 0;i<n;i++){
for(int j = 0;j<n;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
}