#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long ar[1123];
  scanf("%d", &n);
  vector<int> ord;
  for (int i = 2; i <= n; i++) ord.push_back(i);
  random_shuffle(ord.begin(), ord.end());
  int seg = ord[0];
  for (auto el : ord) {
    if (el != seg) {
      printf("2 %d %d %d\n", 1, seg, el);
      fflush(stdout);
      int sg;
      scanf("%d", &sg);
      if (sg == -1) seg = el;
    }
  }
  long long mx = 0;
  int idMx;
  for (auto el : ord) {
    if (el != seg) {
      printf("1 %d %d %d\n", 1, seg, el);
      fflush(stdout);
      long long area;
      scanf("%lld", &area);
      ar[el] = area;
      if (area > mx) {
        mx = area;
        idMx = el;
      }
    }
  }
  set<pair<long long, int>> fi, se;
  for (auto el : ord) {
    if (el != seg && el != idMx) {
      printf("2 %d %d %d\n", 1, idMx, el);
      fflush(stdout);
      int sg;
      scanf("%d", &sg);
      if (sg == 1)
        se.insert({-ar[el], el});
      else
        fi.insert({ar[el], el});
    }
  }
  printf("0 1 %d", seg);
  for (auto el : fi) {
    printf(" %d", el.second);
  }
  printf(" %d", idMx);
  for (auto el : se) {
    printf(" %d", el.second);
  }
  printf("\n");
}
