#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int K,s=0;
	cin >> K;
	vector<vector<int>> g(K, vector<int>(K));

	rep(i,K)
		rep(j,K)
			g.at(i).at(j) = gcd(i+1, j+1);
		
	rep(i,K)
		rep(j,K)
			rep(k,K) {
				s += g.at(g.at(i+1).at(j+1)).at(k+1);
				cout << s << endl;
			}

	cout << s << endl;
}