#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1007;
int n;
vector<int> ans, l, r, p1, p2, p3, p4;
long long dis[N];
long long qry(int t, int i, int j, int k) {
  printf("%d %d %d %d\n", t, i, j, k);
  fflush(stdout);
  long long res;
  scanf("%lld", &res);
  return res;
}
void Init() {
  ans.clear();
  l.clear();
  r.clear();
}
int Solve() {
  for (int i = (3); i < (n + 1); ++i) {
    long long res = qry(2, 1, 2, i);
    if (res == 1)
      l.push_back(i);
    else
      r.push_back(i);
  }
  ans.push_back(1);
  if ((int)(r).size()) {
    long long mx = -LINF, id;
    for (auto o : r) {
      long long res = qry(1, 1, 2, o);
      dis[o] = res;
      if (res > mx) {
        mx = res;
        id = o;
      }
    }
    p4.clear();
    p1.clear();
    for (auto o : r)
      if (o != id) {
        long long res = qry(2, 1, id, o);
        if (res == 1)
          p1.push_back(o);
        else
          p4.push_back(o);
      }
    sort((p4).begin(), (p4).end(),
         [](int a, int b) { return dis[a] < dis[b]; });
    sort((p1).begin(), (p1).end(),
         [](int a, int b) { return dis[a] > dis[b]; });
    for (auto o : p4) ans.push_back(o);
    ans.push_back(id);
    for (auto o : p1) ans.push_back(o);
  }
  ans.push_back(2);
  if ((int)(l).size()) {
    long long mx = -LINF, id;
    for (auto o : l) {
      long long res = qry(1, 1, 2, o);
      dis[o] = res;
      if (res > mx) {
        mx = res;
        id = o;
      }
    }
    p2.clear();
    p3.clear();
    for (auto o : l)
      if (o != id) {
        long long res = qry(2, 1, id, o);
        if (res == 1)
          p3.push_back(o);
        else
          p2.push_back(o);
      }
    sort((p2).begin(), (p2).end(),
         [](int a, int b) { return dis[a] < dis[b]; });
    sort((p3).begin(), (p3).end(),
         [](int a, int b) { return dis[a] > dis[b]; });
    for (auto o : p2) ans.push_back(o);
    ans.push_back(id);
    for (auto o : p3) ans.push_back(o);
  }
  printf("0");
  for (auto o : ans) printf(" %d", o);
  return puts("");
}
int main() {
  scanf("%d", &n);
  Init();
  Solve();
  return 0;
}
