#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<long long int, int> > d[2];
int lv[1009];
int rv[1009];
int ll, rl;
void pickup(int base, vector<pair<long long int, int> >& v) {
  ll = rl = 0;
  if (v.size() < 1) return;
  int vn = v.size();
  int i, j, k;
  ll = rl = 1;
  lv[0] = v[vn - 1].second;
  rv[0] = v[vn - 1].second;
  for (i = vn - 2; i >= 0; i--) {
    int type;
    int ti = v[i].second;
    printf("2 %d %d %d\n", base, lv[ll - 1], ti);
    fflush(stdout);
    scanf("%d", &type);
    if (type == 1) {
      lv[ll++] = ti;
    } else {
      rv[rl++] = ti;
    }
  }
}
int result[1009];
int resl;
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 3; i <= n; i++) {
    int type;
    long long int area;
    printf("2 1 2 %d\n", i);
    fflush(stdout);
    scanf("%d", &type);
    if (type == 1) {
      printf("1 1 2 %d\n", i);
      fflush(stdout);
      scanf("%lld", &area);
      d[0].push_back(pair<long long int, int>(area, i));
    } else {
      printf("1 1 2 %d\n", i);
      fflush(stdout);
      scanf("%lld", &area);
      d[1].push_back(pair<long long int, int>(area, i));
    }
  }
  sort(d[0].begin(), d[0].end());
  sort(d[1].begin(), d[1].end());
  pickup(1, d[1]);
  result[resl++] = 1;
  while (rl--) {
    result[resl++] = rv[rl];
  }
  for (i = 1; i < ll; i++) {
    result[resl++] = lv[i];
  }
  pickup(2, d[0]);
  result[resl++] = 2;
  while (rl--) {
    result[resl++] = rv[rl];
  }
  for (i = 1; i < ll; i++) {
    result[resl++] = lv[i];
  }
  printf("0");
  for (i = 0; i < resl; i++) {
    printf(" %d", result[i]);
  }
  printf("\n");
  fflush(stdout);
}
