#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define OYY LLONG_MAX
#define mod 1000000007
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 55
#define fi first
#define se second
#define pb push_back
int n;
int maxi=0,cur_max=0;
inline void bir(){
for(int i=0;i<12;i++){
cout<<i+maxi<<" ";
cur_max=max(cur_max,i+maxi);
}
cout<<'\n';
}
inline void uc(){
int dizi1[12]={1,2,3,4,5,6,13,14,15,16,17,18};
int dizi2[12]={1,2,3,4,5,6,7,8,9,10,11,12};
int dizi3[12]={7,8,9,10,11,12,13,14,15,16,17,18};
for(int i=0;i<12;i++){
cout<<maxi+dizi1[i]-1<<" ";
cur_max=max(cur_max,maxi+dizi1[i]-1);
}
cout<<'\n';
for(int i=0;i<12;i++){
cout<<maxi+dizi2[i]-1<<" ";
cur_max=max(cur_max,maxi+dizi2[i]-1);
}
cout<<'\n';
for(int i=0;i<12;i++){
cout<<maxi+dizi3[i]-1<<" ";
cur_max=max(cur_max,maxi+dizi3[i]-1);
}
cout<<'\n';
}
int32_t main(){
faster
cin>>n;
while(n && n-3>=0){
uc();
n-=3;
maxi=cur_max+1;
}
while(n--){
bir();
maxi=cur_max+1;
}
return 0;
}