#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n;
vector<int> L, R, ans;
long long h[N];
long long ask1(int i, int j, int k) {
  cout << 1 << ' ' << i << ' ' << j << ' ' << k << endl;
  long long ans;
  cin >> ans;
  return ans;
}
int ask2(int i, int j, int k) {
  cout << 2 << ' ' << i << ' ' << j << ' ' << k << endl;
  int ans;
  cin >> ans;
  return ans;
}
bool cmp(int x, int y) { return h[x] < h[y]; }
void solve(int l, int r, vector<int> L) {
  if (L.size() == 0) {
    ans.push_back(l);
    return;
  } else if (L.size() == 1) {
    ans.push_back(l);
    ans.push_back(L[0]);
    return;
  }
  long long height = 0;
  int idx = 0;
  for (int i = 0; i < (int)L.size(); ++i) {
    h[L[i]] = ask1(l, r, L[i]);
    if (height < h[L[i]]) {
      height = h[L[i]], idx = L[i];
    }
  }
  vector<int> nL, nR;
  for (int i = 0; i < (int)L.size(); ++i) {
    if (L[i] == idx) continue;
    if (ask2(l, idx, L[i]) == 1)
      nL.push_back(L[i]);
    else
      nR.push_back(L[i]);
  }
  sort(nL.begin(), nL.end(), cmp);
  sort(nR.begin(), nR.end(), cmp);
  ans.push_back(l);
  for (int i = 0; i < (int)nL.size(); ++i) {
    ans.push_back(nL[i]);
  }
  ans.push_back(idx);
  for (int i = (int)nR.size() - 1; i >= 0; --i) {
    ans.push_back(nR[i]);
  }
}
int main(void) {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 3; i <= n; ++i) {
    if (ask2(1, 2, i) == 1)
      L.push_back(i);
    else
      R.push_back(i);
  }
  solve(1, 2, L);
  solve(2, 1, R);
  cout << 0 << ' ' << 1 << ' ';
  for (int i = ans.size() - 1; i >= 1; --i) cout << ans[i] << ' ';
  return 0;
}
