#include <bits/stdc++.h>
using namespace std;
template <typename T>
void cetak(T t) {
  cout << t << ')' << endl;
}
template <typename T, typename... V>
void cetak(T t, V... v) {
  cout << t;
  if (sizeof...(v)) cerr << ", ";
  cetak(v...);
}
const int MOD = 1e9 + 7;
const int mx = 1e5 + 10;
int x[mx], y[mx];
long long tanya1(int i, int j, int k) {
  cout << 1 << ' ' << i + 1 << ' ' << j + 1 << ' ' << k + 1 << endl;
  long long ret;
  cin >> ret;
  return ret;
}
int tanya2(int i, int j, int k) {
  cout << 2 << ' ' << i + 1 << ' ' << j + 1 << ' ' << k + 1 << endl;
  int ret;
  cin >> ret;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  iota(a.begin(), a.end(), 0);
  vector<int> kiri, kanan;
  vector<long long> val(n);
  for (int i = 2; i < n; i++) {
    int sign = tanya2(0, 1, i);
    long long luas = tanya1(0, 1, i);
    if (sign == -1)
      kanan.push_back(i);
    else
      kiri.push_back(i);
    val[i] = luas;
  }
  int makskiri = -1, makskanan = -1;
  for (int i : kiri) {
    if (makskiri == -1 || val[i] > val[makskiri]) makskiri = i;
  }
  for (int i : kanan) {
    if (makskanan == -1 || val[i] > val[makskanan]) makskanan = i;
  }
  vector<int> kirikiri, kirikanan, kanankanan, kanankiri;
  for (int i : kiri) {
    if (i == makskiri) continue;
    int sign = tanya2(0, makskiri, i);
    if (sign == 1)
      kirikiri.push_back(i);
    else
      kirikanan.push_back(i);
  }
  for (int i : kanan) {
    if (i == makskanan) continue;
    int sign = tanya2(0, makskanan, i);
    if (sign == -1)
      kanankanan.push_back(i);
    else
      kanankiri.push_back(i);
  }
  sort(kirikiri.begin(), kirikiri.end(),
       [&](int x, int y) { return val[x] > val[y]; });
  sort(kirikanan.begin(), kirikanan.end(),
       [&](int x, int y) { return val[x] < val[y]; });
  sort(kanankanan.begin(), kanankanan.end(),
       [&](int x, int y) { return val[x] < val[y]; });
  sort(kanankiri.begin(), kanankiri.end(),
       [&](int x, int y) { return val[x] > val[y]; });
  vector<int> ans;
  ans.push_back(0);
  for (int i : kanankanan) ans.push_back(i);
  if (makskanan != -1) ans.push_back(makskanan);
  for (int i : kanankiri) ans.push_back(i);
  ans.push_back(1);
  for (int i : kirikanan) ans.push_back(i);
  if (makskiri != -1) ans.push_back(makskiri);
  for (int i : kirikiri) ans.push_back(i);
  cout << 0;
  for (int i : ans) cout << ' ' << i + 1;
  cout << endl;
}
