#include <bits/stdc++.h>
using namespace std;
vector<pair<int64_t, int> > ss;
vector<int> ss1, ss2;
int sgn[11111];
int main() {
  int n;
  scanf("%i", &n);
  int pi = 1;
  for (int i = 2; i < n; i++) {
    printf("2 %i %i %i\n", 0 + 1, pi + 1, i + 1);
    fflush(stdout);
    int ans;
    scanf("%i", &ans);
    if (ans < 0) pi = i;
  }
  for (int i = 0; i < n; i++) {
    if (i != 0 && i != pi) {
      printf("1 %i %i %i\n", 0 + 1, pi + 1, i + 1);
      fflush(stdout);
      int64_t ans;
      scanf("%lld", &ans);
      ss.push_back({ans, i});
    }
  }
  sort(ss.begin(), ss.end());
  int top = ss[ss.size() - 1].second;
  for (int i = 0; i < n; i++) {
    if (i != 0 && i != pi && top != i) {
      printf("2 %i %i %i\n", top + 1, 0 + 1, i + 1);
      fflush(stdout);
      int ans;
      scanf("%i", &ans);
      sgn[i] = ans;
    }
  }
  for (int i = 0; i < ss.size() - 1; i++) {
    if (sgn[ss[i].second] > 0)
      ss1.push_back(ss[i].second);
    else
      ss2.push_back(ss[i].second);
  }
  static int ans[11111];
  ans[0] = 0;
  ans[1] = pi;
  int aa = 2;
  for (int i = 0; i < ss1.size(); i++) ans[aa++] = ss1[i];
  ans[aa++] = top;
  for (int i = 0; i < ss2.size(); i++) ans[aa++] = ss2[ss2.size() - 1 - i];
  printf("0 ");
  for (int i = 0; i < n; i++) printf("%i ", ans[i] + 1);
  printf("\n");
  fflush(stdout);
}
