#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
vector<vector<int>> a;
a.push_back({0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
a.push_back({0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
a.push_back({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
for (int t = 1; t <= 2; t++) {
for (int i = 0; i < 3; i++) {
vector<int> b = a[i];
for (int j = 0; j < 12; j++) {
b[j] += t * 12;
}
a.push_back(b);
}
}
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (auto x : a[i]) {
cout << x << ' ';
}
cout << '\n';
}
return 0;
}