#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 7, mod = 998244353, MAXN = 1e6 + 7;
const double eps = 1e-9;
const long long inf = 1e18;
mt19937 rnd(time(0));
long long n;
long long get(long long a, long long b, long long c, long long d) {
  cout << a << " " << b << " " << c << " " << d << endl;
  long long p;
  cin >> p;
  return p;
}
struct state {
  long long dir, s, ver;
};
void solve() {
  cin >> n;
  vector<pair<long long, long long> > u, d;
  for (long long i = 3; i <= n; ++i) {
    long long t = get(2, 1, i, 2);
    if (t == -1)
      u.emplace_back(get(1, 1, 2, i), i);
    else
      d.emplace_back(get(1, 1, 2, i), i);
  }
  sort(d.begin(), d.end());
  sort(u.begin(), u.end());
  vector<state> d1, u1;
  for (long long i = 0; i < (long long)d.size() - 1; ++i) {
    d1.push_back(
        {get(2, 1, d[i].second, d.back().second), d[i].first, d[i].second});
  }
  for (long long i = 0; i < (long long)u.size() - 1; ++i) {
    u1.push_back(
        {get(2, 1, u[i].second, u.back().second), u[i].first, u[i].second});
  }
  vector<pair<long long, long long> > L, R;
  for (auto v : d1) {
    if (v.dir == 1) {
      L.emplace_back(v.s, v.ver);
    } else {
      R.emplace_back(v.s, v.ver);
    }
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  reverse(R.begin(), R.end());
  cout << "0 1 ";
  for (auto v : L) cout << v.second << " ";
  if (d.size()) cout << d.back().second << " ";
  for (auto v : R) cout << v.second << " ";
  cout << "2 ";
  L.clear();
  R.clear();
  for (auto v : u1) {
    if (v.dir == 1) {
      R.emplace_back(v.s, v.ver);
    } else {
      L.emplace_back(v.s, v.ver);
    }
  }
  sort(R.begin(), R.end());
  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());
  for (auto v : R) cout << v.second << " ";
  if (u.size()) cout << u.back().second << " ";
  for (auto v : L) cout << v.second << " ";
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  long long t = 1;
  for (long long i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
