#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
long long query(long long t, long long i, long long j, long long k) {
  printf("%lld %lld %lld %lld\n", t, i, j, k);
  fflush(stdout);
  long long res;
  scanf("%lld", &res);
  fflush(stdout);
  return res;
}
long long n;
vector<long long> l, r;
struct node {
  long long x, v;
  node(long long a = 0, long long b = 0) { x = a, v = b; }
} ans[N];
struct newt {
  long long id, s, f;
  newt(long long a = 0, long long b = 0, long long c = 0) {
    id = a, s = b, f = c;
  }
  bool operator<(const newt &a) const { return s > a.s; }
} temp1[N], temp2[N];
bool cmp(node a, node b) { return a.v < b.v; }
int main() {
  scanf("%lld", &n);
  for (long long i = 3; i <= n; i++) {
    long long res = query(2, 1, 2, i);
    if (res == 1)
      r.push_back(i);
    else
      l.push_back(i);
  }
  long long a = l.size();
  long long b = r.size();
  ans[1].v = 1, ans[1].x = 1;
  ans[2].v = a + 2, ans[2].x = 2;
  long long cnt = 0;
  for (long long v : l) {
    long long t = query(1, 1, 2, v);
    temp1[++cnt] = newt(v, t, 0);
  }
  sort(temp1 + 1, temp1 + cnt + 1);
  long long sum1 = 0, sum2 = 0;
  long long pos = temp1[1].id;
  for (long long i = 2; i <= cnt; i++) {
    long long t = query(2, 1, pos, temp1[i].id);
    temp1[i].f = t;
    if (t == -1)
      sum1++;
    else
      sum2++;
  }
  ans[pos].v = sum1 + 2, ans[pos].x = pos;
  long long v1 = sum1 + 2, v2 = sum1 + 2;
  for (long long i = 2; i <= cnt; i++) {
    if (temp1[i].f == -1)
      ans[temp1[i].id].v = --v1, ans[temp1[i].id].x = temp1[i].id;
    else
      ans[temp1[i].id].v = ++v2, ans[temp1[i].id].x = temp1[i].id;
  }
  cnt = sum1 = sum2 = 0;
  for (long long v : r) {
    long long t = query(1, 1, 2, v);
    temp2[++cnt] = newt(v, t, 0);
  }
  sort(temp2 + 1, temp2 + cnt + 1);
  pos = temp2[1].id;
  for (long long i = 2; i <= cnt; i++) {
    long long t = query(2, 1, pos, temp2[i].id);
    temp2[i].f = t;
    if (t == -1)
      sum1++;
    else
      sum2++;
  }
  ans[pos].v = a + 3 + sum1, ans[pos].x = pos;
  v1 = ans[pos].v, v2 = ans[pos].v;
  for (long long i = 2; i <= cnt; i++) {
    if (temp2[i].f == -1)
      ans[temp2[i].id].v = --v1, ans[temp2[i].id].x = temp2[i].id;
    else
      ans[temp2[i].id].v = ++v2, ans[temp2[i].id].x = temp2[i].id;
  }
  sort(ans + 1, ans + 1 + n, cmp);
  printf("0");
  for (long long i = 1; i <= n; i++) {
    printf(" %lld", ans[i].x);
  }
  puts("");
  return 0;
}
