#include <bits/stdc++.h>
using namespace std;
long long ask(int t, int a, int b, int c) {
  printf("%d %d %d %d\n", t, a, b, c);
  fflush(stdout);
  long long first;
  scanf("%lld", &first);
  return first;
}
int main() {
  int n;
  scanf("%d", &n);
  int X = 1, Y = 2;
  for (int i = 3; i <= n; i++) {
    if (ask(2, X, Y, i) == -1) Y = i;
  }
  vector<pair<long long, int> > vec;
  for (int i = 2; i <= n; i++) {
    if (i == Y) continue;
    vec.push_back({ask(1, X, Y, i), i});
  }
  sort(vec.begin(), vec.end());
  deque<int> deq = {X, Y};
  for (int i = 0; i + 1 < vec.size(); i++) {
    if (ask(2, X, vec[i].second, vec[i + 1].second) == 1)
      deq.push_back(vec[i].second);
    else
      deq.push_front(vec[i].second);
  }
  deq.push_back(vec.back().second);
  while (deq[0] != 1) deq.push_back(deq.front()), deq.pop_front();
  printf("0 ");
  for (int i = 0; i < deq.size(); i++)
    printf("%d%c", deq[i], (i == n - 1) ? '\n' : ' ');
}
