#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <numeric>

using namespace std;

vector<bool> v;

bool test(vector<bool>&b, int n, vector<int>&r)
{
    if (n == b.size())
    {
        for(auto i: r) cout << setw(3) << i; cout << endl;
        return true;
    }
    int sum = accumulate(r.begin(),r.end(),0);
    for(int j =0; j < b.size(); ++j)
    {
        if (b[j] == false)
        {
            if (sum % (j+1) != 0) continue;
            b[j] = true;
            r.push_back(j+1);
            bool res = test(b,n+1,r);
            r.pop_back();
            b[j] = false;
            if (res) return true;
        }
    }
    return false;
}


int main(int argc, const char * argv[])
{
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i) v.push_back(false);

    vector<int> r;
    test(v,0,r);

}
