#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int n, a[maxn], b[maxn], szp, sza, szb;
pair<long long, int> p[maxn];
inline long long query(int op, int i, int j, int k) {
  printf("%d %d %d %d\n", op, i, j, k);
  fflush(stdout);
  long long x;
  scanf("%lld", &x);
  return x;
}
int main() {
  scanf("%d", &n);
  int nxt = 2;
  for (int i = 3; i <= n; i++)
    if (query(2, 1, i, nxt) == 1) nxt = i;
  for (int i = 2; i <= n; i++)
    if (i != nxt) p[++szp] = pair<long long, int>(query(1, 1, nxt, i), i);
  sort(p + 1, p + szp + 1);
  for (int i = 1; i < szp; i++)
    if (query(2, 1, p[i].second, p[szp].second) == 1)
      a[++sza] = p[i].second;
    else
      b[++szb] = p[i].second;
  printf("0 1 %d ", nxt);
  for (int i = 1; i <= sza; i++) printf("%d ", a[i]);
  printf("%d ", p[szp].second);
  for (int i = szb; i; i--) printf("%d ", b[i]);
  putchar('\n');
  return 0;
}
