#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
long long square(long long i, long long j, long long k) {
  cout << 1 << " " << i << " " << j << " " << k << endl;
  long long s;
  cin >> s;
  return s;
}
long long sign(long long i, long long j, long long k) {
  cout << 2 << " " << i << " " << j << " " << k << endl;
  long long s;
  cin >> s;
  return s;
}
long long h[N];
vector<long long> answer;
void solve(long long a, long long b, vector<long long> vert) {
  for (long long e : vert) {
    h[e] = square(a, b, e);
  }
  sort(vert.begin(), vert.end(),
       [&](long long i, long long j) { return h[i] > h[j]; });
  vector<long long> lef, rig;
  while (vert.size() > 1) {
    long long v = vert.back();
    vert.pop_back();
    long long u = vert.back();
    if (sign(a, u, v) < 0) {
      rig.push_back(v);
    } else {
      lef.push_back(v);
    }
  }
  if (vert.size() == 1) {
    lef.push_back(vert.back());
  }
  answer.insert(answer.end(), rig.begin(), rig.end());
  reverse(lef.begin(), lef.end());
  answer.insert(answer.end(), lef.begin(), lef.end());
}
long long n;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  answer.push_back(1);
  vector<long long> fi, se;
  for (long long i = 3; i <= n; ++i) {
    long long s = sign(1, 2, i);
    assert(s);
    if (s < 0) {
      fi.push_back(i);
    } else {
      se.push_back(i);
    }
  }
  solve(1, 2, fi);
  answer.push_back(2);
  solve(2, 1, se);
  assert((long long)answer.size() == n);
  cout << 0 << " ";
  for (long long e : answer) {
    cout << e << " ";
  }
  cout << endl;
  return 0;
}
