#include <bits/stdc++.h>
using namespace std;
long long mod1 = 1e17 + 3;
long long mod = 1e9 + 7;
const long long N = 3e5 + 10;
long long n, f, g;
vector<pair<long long, long long> > s1, s2, x1, x2, x3, x4;
long long area(int i, int j, int k) {
  long long x;
  cout << "1 " << i << " " << j << " " << k << endl;
  cin >> x;
  return x;
}
int ori(int i, int j, int k) {
  int x;
  cout << "2 " << i << " " << j << " " << k << endl;
  cin >> x;
  return x;
}
void solve() {
  cin >> n;
  for (int i = 3; i <= n; i++) {
    int o = ori(1, 2, i);
    if (o == 1)
      s1.push_back(make_pair(0, i));
    else
      s2.push_back(make_pair(0, i));
  }
  long long x;
  for (int i = 0; i < s1.size(); i++) {
    long long x = area(1, 2, s1[i].second);
    long long y = s1[i].second;
    s1[i] = make_pair(x, y);
  }
  for (int i = 0; i < s2.size(); i++) {
    long long x = area(1, 2, s2[i].second);
    long long y = s2[i].second;
    s2[i] = make_pair(x, y);
  }
  sort(s1.begin(), s1.end()), sort(s2.begin(), s2.end());
  if (!s1.empty()) {
    int y = s1[(long long)s1.size() - 1].second;
    for (int i = 0; i < (long long)s1.size() - 1; i++) {
      int o = ori(1, y, s1[i].second);
      if (o == 1)
        x1.push_back(s1[i]);
      else
        x2.push_back(s1[i]);
    }
    x1.push_back(s1[(long long)s1.size() - 1]);
  }
  if (!s2.empty()) {
    int y = s2[(long long)s2.size() - 1].second;
    for (int i = 0; i < (long long)s2.size() - 1; i++) {
      int o = ori(1, y, s2[i].second);
      if (o == 1)
        x3.push_back(s2[i]);
      else
        x4.push_back(s2[i]);
    }
    x3.push_back(s2[(long long)s2.size() - 1]);
  }
  reverse(x1.begin(), x1.end());
  reverse(x3.begin(), x3.end());
  vector<int> ans;
  ans.push_back(1);
  for (auto it : x4) ans.push_back(it.second);
  for (auto it : x3) ans.push_back(it.second);
  ans.push_back(2);
  for (auto it : x2) ans.push_back(it.second);
  for (auto it : x1) ans.push_back(it.second);
  cout << "0 ";
  for (auto it : ans) cout << it << " ";
  cout << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
