#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3;
int n;
long long S[maxn + 5];
long long query(int t, int i, int j, int k) {
  long long ans = 0;
  printf("%d %d %d %d\n", t, i, j, k);
  fflush(stdout);
  scanf("%lld", &ans);
  return ans;
}
vector<pair<long long, int> > L, R, ans[4];
vector<int> res;
void solveR() {
  if (R.empty()) {
    ans[1].push_back(pair<long long, int>(-1, 1));
    return;
  }
  long long maxS = 0;
  int pos = -1;
  for (int i = 0; i < R.size(); ++i) {
    if (pos == -1 || R[i].first > maxS) {
      pos = i;
      maxS = R[i].first;
    }
  }
  for (int i = 0; i < R.size(); ++i) {
    if (pos == i) continue;
    int sign = query(2, 1, R[i].second, R[pos].second);
    if (sign == 1)
      ans[0].push_back(R[i]);
    else
      ans[1].push_back(R[i]);
  }
  sort(ans[0].begin(), ans[0].end());
  sort(ans[1].begin(), ans[1].end(), greater<pair<long long, int> >());
  ans[0].push_back(R[pos]);
  ans[1].push_back(pair<long long, int>(-1, 1));
}
void solveL() {
  if (L.empty()) {
    ans[3].push_back(pair<long long, int>(-1, 2));
    return;
  }
  long long maxS = 0;
  int pos = -1;
  for (int i = 0; i < L.size(); ++i) {
    if (pos == -1 || L[i].first > maxS) {
      pos = i;
      maxS = L[i].first;
    }
  }
  for (int i = 0; i < L.size(); ++i) {
    if (pos == i) continue;
    int sign = query(2, 1, L[i].second, L[pos].second);
    if (sign == 1)
      ans[2].push_back(L[i]);
    else
      ans[3].push_back(L[i]);
  }
  sort(ans[2].begin(), ans[2].end());
  sort(ans[3].begin(), ans[3].end(), greater<pair<long long, int> >());
  ans[2].push_back(L[pos]);
  ans[3].push_back(pair<long long, int>(-1, 2));
}
int main() {
  scanf("%d", &n);
  for (int i = 3; i <= n; ++i) {
    S[i] = query(1, 1, 2, i);
    if (query(2, 1, 2, i) == -1) S[i] = -S[i];
  }
  for (int i = 3; i <= n; ++i) {
    if (S[i] < 0)
      L.push_back(pair<long long, int>(-S[i], i));
    else
      R.push_back(pair<long long, int>(S[i], i));
  }
  solveL();
  solveR();
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < ans[i].size(); ++j) res.push_back(ans[i][j].second);
  int st;
  for (int i = 0; i < n; ++i) {
    if (res[i] == 1) {
      st = i;
      break;
    }
  }
  printf("0");
  for (int i = st; i < res.size(); ++i) printf(" %d", res[i]);
  for (int i = 0; i < st; ++i) printf(" %d", res[i]);
  printf("\n");
  return 0;
}
