//一种递归解法
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
void str(int n,vector[HTML_REMOVED]>&arr);
int main(){
int n;
while(cin>>n){
if(n==0){
break;
}
vector<vector<int>> arr(n,vector<int>(n));
str(n,arr);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<arr[i][j]<<" ";
}
cout<<'\n';
}
cout<<'\n';
}
return 0;
}
void str(int n,vector[HTML_REMOVED]>&arr){
static int num=0;
if(num>=n){
num=0;
return ;
}
for(int i=num;i<n;i){
for(int j=num;j<n;j){
arr[i][j]=num+1;
}
}
num++;
str(n-1,arr);
}