#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > atas, bawah;
vector<long long> rans;
long long n;
long long ask(long long a, long long b, long long c, long long d) {
  cout << a << " " << b << " " << c << " " << d << endl;
  fflush(stdout);
  cin >> a;
  return a;
}
void f(vector<pair<long long, long long> > v) {
  if (v.size() == 0) return;
  vector<long long> ret, ki, ka;
  sort(v.rbegin(), v.rend());
  long long a = v[0].second;
  for (long long i = 1; i < v.size(); i++) {
    long long x = ask(2, 1, a, v[i].second);
    if (x == 1)
      ka.push_back(v[i].second);
    else
      ki.push_back(v[i].second);
  }
  reverse(ki.begin(), ki.end());
  for (auto g : ki) rans.push_back(g);
  rans.push_back(a);
  for (auto g : ka) rans.push_back(g);
}
signed main() {
  cin >> n;
  for (long long i = 3; i <= n; i++) {
    long long x = ask(1, 1, 2, i);
    long long y = ask(2, 1, 2, i);
    if (y == 1) {
      atas.push_back({x, i});
    } else {
      bawah.push_back({x, i});
    }
  }
  rans.push_back(0);
  rans.push_back(1);
  f(bawah);
  rans.push_back(2);
  f(atas);
  for (auto g : rans) {
    cout << g << " ";
  }
  cout << endl;
  fflush(stdout);
}
