#include <bits/stdc++.h>
using namespace std;
int n,a[10][10];
void fun(int k,int t,int x,int y){
     if(x <= n && y <= n){
         if(k % 2 == 1){
             while(x >= 1 && y <= n){
                a[x][y] = t;
                x--;
                y++;
                t++;
             }
             x++;y--; 
         }else{
            while(x <= n && y >= 1){
                a[x][y] = t;
                x++;
                y--;
                t++;
            }  
            x--;y++;
         }
         if(k<n){
             if(k % 2 == 1){
                  fun(k+1,t,x,y+1);     
            }else{
                  fun(k+1,t,x+1,y);
            }
        }else{
             if(k % 2 == 0){
                  fun(k+1,t,x,y+1);     
             }else{
                  fun(k+1,t,x+1,y);
             }  
        } 
     }
}
 
int main(){
    int i,j;
    cin>>n;
    fun(1,1,1,1);
    for(i = 1;i <= n;i++){
        for(j = 1;j <= n;j++){
            cout<<setw(5)<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}
/**************************************************************
	Problem: 1382
	User: wengsihan
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2072 kb
****************************************************************/