#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long l, r;
long long ans[N];
long long store1[N], store2[N];
vector<pair<long long, long long> > lft, rght;
long long query1(long long i, long long j, long long k) {
  cout << 1 << " " << i << " " << j << " " << k << endl;
  long long x;
  cin >> x;
  return x;
}
long long query2(long long i, long long j, long long k) {
  cout << 2 << " " << i << " " << j << " " << k << endl;
  long long x;
  cin >> x;
  return x;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 3; i <= n; i++) {
    long long side = query2(1, 2, i);
    long long area = query1(1, 2, i);
    if (side == 1) {
      l++;
      lft.push_back({area, i});
    } else {
      r++;
      rght.push_back({area, i});
    }
  }
  sort(lft.rbegin(), lft.rend());
  ans[1] = 1;
  long long idx = 1;
  if (lft.size()) {
    long long j = lft[0].second;
    vector<pair<long long, long long> > L, R;
    for (long long k = 1; k < lft.size(); k++) {
      long long side = query2(1, j, lft[k].second);
      if (side == 1)
        L.push_back({lft[k].first, lft[k].second});
      else
        R.push_back({lft[k].first, lft[k].second});
    }
    sort(L.begin(), L.end());
    sort(R.rbegin(), R.rend());
    for (auto it : L) ans[++idx] = it.second;
    ans[++idx] = j;
    for (auto it : R) ans[++idx] = it.second;
  }
  ans[++idx] = 2;
  sort(rght.rbegin(), rght.rend());
  if (rght.size()) {
    long long j = rght[0].second;
    vector<pair<long long, long long> > L, R;
    for (long long k = 1; k < rght.size(); k++) {
      long long side = query2(1, j, rght[k].second);
      if (side == 1)
        L.push_back({rght[k].first, rght[k].second});
      else
        R.push_back({rght[k].first, rght[k].second});
    }
    sort(L.begin(), L.end());
    sort(R.rbegin(), R.rend());
    for (auto it : L) ans[++idx] = it.second;
    ans[++idx] = j;
    for (auto it : R) ans[++idx] = it.second;
  }
  cout << 0 << " ";
  cout << ans[1] << " ";
  for (long long i = n; i >= 2; i--) cout << ans[i] << " ";
  return 0;
}
