#include <bits/stdc++.h>
using namespace std;
vector<int> solve(vector<int>& pts, int dir) {
  int x = 1, y = 2;
  if (dir) {
    swap(x, y);
  }
  vector<pair<long long, int> > areas;
  for (auto idx : pts) {
    cout << "1 " << x << " " << y << " " << idx + 1 << endl;
    long long ret;
    cin >> ret;
    areas.push_back(make_pair(ret, idx));
  }
  sort(areas.begin(), areas.end());
  if (areas.size() == 0) {
    return {};
  }
  int mx = areas.back().second;
  map<int, long long> ar;
  for (auto p : areas) {
    ar[p.second] = p.first;
  }
  vector<pair<long long, int> > left;
  vector<pair<long long, int> > right;
  for (auto idx : pts) {
    if (idx != mx) {
      cout << "2 " << x << " " << mx + 1 << " " << idx + 1 << endl;
      int sgn;
      cin >> sgn;
      if (sgn == 1) {
        left.push_back(make_pair(ar[idx], idx));
      } else {
        right.push_back(make_pair(ar[idx], idx));
      }
    }
  }
  sort(left.begin(), left.end());
  sort(right.begin(), right.end());
  reverse(right.begin(), right.end());
  vector<int> res;
  for (auto p : left) {
    res.push_back(p.second);
  }
  res.push_back(mx);
  for (auto p : right) {
    res.push_back(p.second);
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  vector<int> left;
  vector<int> right;
  for (int i = 2; i < n; ++i) {
    cout << "2 1 2 " << i + 1 << endl;
    int inp;
    cin >> inp;
    if (inp == 1) {
      left.push_back(i);
    } else {
      right.push_back(i);
    }
  }
  vector<int> orderleft = solve(left, 0);
  vector<int> orderright = solve(right, 1);
  vector<int> res;
  res.push_back(1);
  for (auto x : orderleft) {
    res.push_back(x + 1);
  }
  res.push_back(2);
  for (auto x : orderright) {
    res.push_back(x + 1);
  }
  reverse(res.begin() + 1, res.end());
  cout << "0";
  for (int i = 0; i < res.size(); ++i) {
    cout << " " << res[i];
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  for (int tt = 0; tt < t; ++tt) {
    solve();
  }
  return 0;
}
