#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > left, right;
  vector<long long> sleft, sright, ans;
  for (long long i = 3; i <= n; ++i) {
    long long x, y;
    cout << "2 1 2 " << i << endl;
    cin >> x;
    cout << "1 1 2 " << i << endl;
    cin >> y;
    if (x == 1)
      left.push_back({y, i});
    else
      right.push_back({y, i});
  }
  ans.push_back(1);
  sort(right.begin(), right.end());
  if (right.size() > 0) {
    long long size = right.size();
    long long pivot = right[size - 1].second;
    for (long long i = 0; i < right.size() - 1; ++i) {
      long long x, cur = right[i].second;
      cout << "2 1 " << pivot << ' ' << cur << endl;
      cin >> x;
      if (x == 1)
        sleft.push_back(cur);
      else
        sright.push_back(cur);
    }
    for (long long i = 0; i < sright.size(); ++i) ans.push_back(sright[i]);
    ans.push_back(pivot);
    if (sleft.size() > 0)
      for (long long i = sleft.size() - 1; i >= 0; --i) ans.push_back(sleft[i]);
    sleft.clear();
    sright.clear();
  }
  ans.push_back(2);
  sort(left.begin(), left.end());
  if (left.size() > 0) {
    long long size = left.size();
    long long pivot = left[size - 1].second;
    for (long long i = 0; i < left.size() - 1; ++i) {
      long long x, cur = left[i].second;
      cout << "2 1 " << pivot << ' ' << cur << endl;
      cin >> x;
      if (x == 1)
        sleft.push_back(cur);
      else
        sright.push_back(cur);
    }
    for (long long i = 0; i < sright.size(); ++i) ans.push_back(sright[i]);
    ans.push_back(pivot);
    if (sleft.size() > 0)
      for (long long i = sleft.size() - 1; i >= 0; --i) ans.push_back(sleft[i]);
  }
  cout << '0';
  for (long long a : ans) cout << ' ' << a;
  cout << endl;
}
