#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
const int INF = 1e9 + 7;
//const long long INF = 1e18 + 7;
//const int mod = 998244353;
const int mod = 1e9 + 7;
//const int inv2 = 499122177;
const int mxN = 1e7;
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
//freopen("_.in", "r", stdin);
//freopen("_.out", "w", stdout);
int n; cin >> n;
vector<array<int, 12>> a(n);
for (int i = 0; i < n; ++i)
{
int idx = i % 4;
for (int j = 0; j < 12; ++j)
a[i][j] = j+1 + (idx * 12);
}
for (auto b : a)
{
for (auto c : b)
cout << c << " ";
cout << "\n";
}
return 0;
}