#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
const long long maxn = 1e6 + 1;
long long ask2(long long i, long long j) {
  cout << "2 1 " << i << ' ' << j << endl;
  long long cd;
  cin >> cd;
  return cd;
}
long long mp;
bool usd[1001];
long long ask1(long long i) {
  cout << "1 1 " << mp << ' ' << i << endl;
  long long x;
  cin >> x;
  return x;
}
bool lft(long long x) { return (x == 1); }
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  mp = 2;
  for (long long i = 3; i <= n; i++) {
    if (lft(ask2(i, mp))) mp = i;
  }
  vector<pair<long long, long long> > v;
  for (long long i = 2; i <= n; i++) {
    if (mp == i) continue;
    v.push_back({ask1(i), i});
  }
  vector<long long> ld, rd;
  sort(v.begin(), v.end());
  for (long long i = 0; i < v.size() - 1; i++) {
    if (lft(ask2(v.back().second, v[i].second)))
      rd.push_back(v[i].second);
    else
      ld.push_back(v[i].second);
  }
  cout << "0 1 " << mp << ' ';
  for (long long i = 0; i < ld.size(); i++) cout << ld[i] << ' ';
  cout << v.back().second << ' ';
  for (long long i = (long long)rd.size() - 1; i >= 0; i--)
    cout << rd[i] << ' ';
  cout << endl;
  return 0;
}
