#include <bits/stdc++.h>
using namespace std;
long long askArea(int i, int j, int k) {
  cout << 1 << " " << i << " " << j << " " << k << endl;
  long long x;
  cin >> x;
  return x;
}
int askSign(int i, int j, int k) {
  cout << 2 << " " << i << " " << j << " " << k << endl;
  int x;
  cin >> x;
  return x;
}
void printSolution(vector<int> v) {
  cout << 0;
  for (int i : v) cout << " " << i;
  cout << endl;
  exit(0);
}
void normalize(vector<int> &side) {
  if (side.size() < 2) return;
  long long mx = 0;
  int id = -1;
  vector<pair<long long, int> > vp;
  for (int i : side) {
    vp.emplace_back(askArea(1, 2, i), i);
    if (vp.back().first > mx) {
      mx = vp.back().first;
      id = i;
    }
  }
  assert(id != -1);
  vector<pair<long long, int> > side1, side2;
  for (pair<long long, int> p : vp) {
    if (p.second == id) continue;
    if (askSign(1, id, p.second) > 0)
      side2.push_back(p);
    else
      side1.push_back(p);
  }
  sort(side1.begin(), side1.end());
  sort(side2.rbegin(), side2.rend());
  side.clear();
  for (pair<long long, int> p : side1) side.push_back(p.second);
  side.push_back(id);
  for (pair<long long, int> p : side2) side.push_back(p.second);
}
int main() {
  int n;
  cin >> n;
  vector<int> side1, side2;
  for (int i = 3; i <= n; i++) {
    if (askSign(1, 2, i) > 0)
      side1.push_back(i);
    else
      side2.push_back(i);
  }
  normalize(side1);
  normalize(side2);
  vector<int> solution;
  solution.push_back(1);
  for (int i : side2) solution.push_back(i);
  solution.push_back(2);
  for (int i : side1) solution.push_back(i);
  printSolution(solution);
  return 0;
}
