#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 10, MAX_M = 1e6 + 10;
long long dist[MAX_N];
int query(int i, int j, int k) {
  cout << 2 << " " << i << " " << j << " " << k << endl;
  int res;
  cin >> res;
  return res;
}
void solve() {
  int n;
  cin >> n;
  int v;
  vector<int> first;
  vector<int> r, l;
  if (query(1, 2, 3) > 0) {
    v = 2;
  } else
    v = 3;
  for (int i = 4; i <= n; i++) {
    if (query(1, i, v) > 0) {
      v = i;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (v == i) continue;
    first.push_back(i);
    cout << 1 << " " << i << " " << v << " " << 1 << endl;
    cin >> dist[i];
  }
  sort(first.begin(), first.end(),
       [&](int i, int j) { return dist[i] < dist[j]; });
  for (int i = 0; i < n - 1 - 2; i++) {
    if (query(1, first[i], first[i + 1]) > 0) {
      r.push_back(first[i]);
    } else
      l.push_back(first[i]);
  }
  r.push_back(first.back());
  cout << 0 << ' ' << 1 << ' ' << v;
  for (auto i : r) cout << ' ' << i;
  reverse(l.begin(), l.end());
  for (auto i : l) cout << ' ' << i;
  cout << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
