#include<iostream>
int main() {
int n;
std::cin >> n;//n阶方阵
//动态分配n*n个空间
int** a = new int* [n];
for (int i = 0; i < n; ++i) {
a[i] = new int[n];
}
//******************
int rownum = 1;//横着看上三角第一个值
int colnum = 1;//竖着看下三角第一个值
//*****给上三角赋值*************
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (i <= j) {
a[i - 1][j - 1] = rownum;
rownum++;
}
}
}
//****************************
//*****给下三角赋值*************
for (int j = 1; j <= n; ++j) {
for (int i = 1; i <= n; ++i) {
if (i >= j) {
a[i - 1][j - 1] = colnum;
colnum++;
}
}
}
//*****************************
//****输出部分*****************
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
std::cout << a[i-1][j-1]<<" ";
}
std::cout<<std::endl;
}
//*************************
//********释放内存***********
for (int i = 0; i < n; ++i) {
delete a[i];
}
delete []a;
//***********************
}