#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(vector<T> s) {
  for (auto x : s) cout << x << " ";
  cout << endl;
}
bool ask1(int i, int j, int k) {
  cout << 2 << " " << i << " " << j << " " << k << endl;
  cin >> i;
  return i == 1;
}
long long ask2(int i, int j, int k) {
  cout << 1 << " " << i << " " << j << " " << k << endl;
  long long res;
  cin >> res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(6);
  int n;
  cin >> n;
  int x = 2;
  for (int i = 3; i <= n; i++) {
    if (!ask1(1, x, i)) x = i;
  }
  vector<long long> dist(n + 1, 0);
  int maxi = 0;
  for (int i = 2; i <= n; i++) {
    if (i == x) continue;
    dist[i] = ask2(1, x, i);
    if (dist[i] > dist[maxi]) maxi = i;
  }
  vector<int> L, R;
  for (int i = 2; i <= n; i++) {
    if (i == x || i == maxi) continue;
    if (ask1(1, i, maxi))
      L.push_back(i);
    else
      R.push_back(i);
  }
  sort(L.begin(), L.end(), [&](int i, int j) { return dist[i] < dist[j]; });
  sort(R.begin(), R.end(), [&](int i, int j) { return dist[i] > dist[j]; });
  cout << 0 << " " << 1 << " " << x << " ";
  for (int i : L) cout << i << " ";
  cout << maxi << " ";
  for (int i : R) cout << i << " ";
  cout << endl;
  return 0;
}
