#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  long long top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  long long top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long n, m, i, j, a, b, s[1005];
vector<pair<long long, long long> > s1, s2;
bool lft(long long x, long long y, long long z) {
  cout << 2 << ' ' << x << ' ' << y << ' ' << z << endl << flush;
  long long a;
  cin >> a;
  return a > 0;
}
long long qa(long long x, long long y, long long z) {
  cout << 1 << ' ' << x << ' ' << y << ' ' << z << endl << flush;
  long long a;
  cin >> a;
  return a;
}
int main() {
  cin >> n;
  a = 2;
  for ((i) = (3); (i) <= (n); (i)++) {
    if (lft(1, i, a)) {
      a = i;
    }
  }
  for ((i) = (2); (i) <= (n); (i)++)
    if (i != a) {
      s[i] = qa(1, a, i);
    }
  for ((i) = (2); (i) <= (n); (i)++)
    if (i != a) {
      if (!b || s[i] > s[b]) {
        b = i;
      }
    }
  for ((i) = (2); (i) <= (n); (i)++)
    if (i != a && i != b) {
      if (lft(1, i, b)) {
        s1.push_back(make_pair(s[i], i));
      } else {
        s2.push_back(make_pair(s[i], i));
      }
    }
  printf("0 1 %I64d", a);
  sort((s1).begin(), (s1).end());
  for (__typeof((s1).begin()) it = (s1).begin(); it != (s1).end(); it++)
    printf(" %I64d", it->second);
  printf(" %I64d", b);
  sort((s2).begin(), (s2).end());
  reverse((s2).begin(), (s2).end());
  for (__typeof((s2).begin()) it = (s2).begin(); it != (s2).end(); it++)
    printf(" %I64d", it->second);
  return 0;
}
