#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long inf = 1e9 + 96;
const int N = 2e5;
long long qry(int t, int i, int j, int k) {
  cout << t << ' ' << i << ' ' << j << ' ' << k << endl;
  long long jwb;
  cin >> jwb;
  return jwb;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, long long> > kanan, kiri;
  for (int i = 3; i <= n; i++) {
    int dmn = qry(2, 1, 2, i);
    if (dmn == -1) {
      kanan.push_back({qry(1, 1, 2, i), i});
    } else {
      kiri.push_back({qry(1, 1, 2, i), i});
    }
  }
  vector<pair<long long, long long> > kanan2, kiri2;
  vector<int> ans;
  ans.push_back(1);
  vector<pair<long long, long long> > kanan3, kiri3;
  if (kanan.size()) {
    sort(kanan.begin(), kanan.end(), greater<pair<long long, long long> >());
    for (int i = 1; i < kanan.size(); i++) {
      int dmn = qry(2, 1, kanan[0].second, kanan[i].second);
      if (dmn == -1) {
        kanan3.push_back(kanan[i]);
      } else {
        kiri3.push_back(kanan[i]);
      }
    }
    if (kanan3.size()) {
      sort(kanan3.begin(), kanan3.end());
      for (auto x : kanan3) ans.push_back(x.second);
    }
    ans.push_back(kanan[0].second);
    if (kiri3.size()) {
      sort(kiri3.begin(), kiri3.end(), greater<pair<long long, long long> >());
      for (auto x : kiri3) ans.push_back(x.second);
    }
  }
  ans.push_back(2);
  if (kiri.size()) {
    sort(kiri.begin(), kiri.end(), greater<pair<long long, long long> >());
    for (int i = 1; i < kiri.size(); i++) {
      int dmn = qry(2, 2, kiri[0].second, kiri[i].second);
      if (dmn == -1) {
        kanan2.push_back(kiri[i]);
      } else {
        kiri2.push_back(kiri[i]);
      }
    }
    if (kanan2.size()) {
      sort(kanan2.begin(), kanan2.end());
      for (auto x : kanan2) ans.push_back(x.second);
    }
    ans.push_back(kiri[0].second);
    if (kiri2.size()) {
      sort(kiri2.begin(), kiri2.end(), greater<pair<long long, long long> >());
      for (auto x : kiri2) ans.push_back(x.second);
    }
  }
  cout << "0";
  for (auto x : ans) cout << ' ' << x;
  cout << endl;
}
