#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class A, class B, class C>
struct Triple {
  A first;
  B second;
  C third;
  bool operator<(const Triple &t) const {
    if (first != t.first) return first < first.st;
    if (second != t.second) return second < t.second;
    return third < t.third;
  }
};
const long double EPS = 0.000000001;
const long double INFD32 = 1000000000;
const long long INF64 = 1000000000000000000;
const long long INF32 = 1000000000;
const long long one = 1;
bool iss_ll(long long __1, long long __2) { return 2 * INF64 / __1 >= __2; }
bool equal(double _1, double _2) { return (abs(_1 - _2) < EPS); }
bool iss_sqr(long long &__1) {
  long long __2 = sqrt((long double)__1);
  return __2 * __2 == __1;
};
bool iss_prime(long long __1) {
  for (long long i = 2; i * i <= __1; ++i)
    if (!(__1 % i)) return 0;
  return 1;
}
long long gcd(long long __1, long long __2) {
  while (__1 && __2)
    if (__1 > __2)
      __1 = __1 % __2;
    else
      __2 = __2 % __1;
  return __1 + __2;
}
long long lcm(long long __1, long long __2) {
  return __1 * __2 / (gcd(__1, __2));
}
long long sq_cube(long long x) {
  if (x == 0) return 1;
  long long l = 0, r = 2e6;
  while (l + 1 < r) {
    long long m = (l + r) / 2;
    if (m * m * m > x)
      r = m;
    else
      l = m;
  }
  return l;
}
long long bp(long long a, long long b, long long md) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    a %= md;
    res %= md;
    b >>= 1;
  }
  return res;
}
vector<long long> z_function(string &s) {
  long long n = ((long long)((s).size()));
  vector<long long> ans(n, 0);
  long long l = 0, r = 0;
  for (long long i = 1; i < n; ++i) {
    ans[i] = min(r - i + 1, ans[i - l]);
    while (ans[i] + i < n && s[ans[i]] == s[i + ans[i]]) {
      ++ans[i];
    }
    if (i + ans[i] - 1 > r) {
      l = i, r = i + ans[i] - 1;
    }
    r = max(r, i);
  }
  return ans;
}
long long f1(long long a, long long b, long long c) {
  cout << 1 << " " << a << " " << b << " " << c << endl;
  long long x;
  cin >> x;
  return x;
}
bool f2(long long a, long long b, long long c) {
  cout << 2 << " " << a << " " << b << " " << c << endl;
  long long x;
  cin >> x;
  return (x + 1) / 2;
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long ind = 2;
  for (long long i = 3; i <= n; ++i)
    if (f2(1, ind, i)) ind = i;
  vector<pair<long long, long long> > VEC;
  for (long long i = 2; i <= n; ++i) {
    if (i == ind) continue;
    VEC.push_back({f1(1, ind, i), i});
  }
  sort((VEC).begin(), (VEC).end());
  pair<long long, long long> x = VEC.back();
  VEC.pop_back();
  vector<long long> l, r;
  vector<long long> ans;
  for (pair<long long, long long> i : VEC) {
    if (f2(1, x.second, i.second))
      l.push_back(i.second);
    else
      r.push_back(i.second);
  }
  ans = {1, ind};
  cout << 0 << " ";
  for (long long i : l) ans.push_back(i);
  reverse((r).begin(), (r).end());
  ans.push_back(x.second);
  for (long long i : r) ans.push_back(i);
  reverse((ans).begin(), (ans).end());
  cout << 1 << " ";
  ans.pop_back();
  for (long long i : ans) cout << i << " ";
  cout << endl;
  return 0;
}
