#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
int n, aa, bb;
int x[7] = {0, -2, 3, -2, 1, 0, 2};
int y[7] = {0, 1, -1, -1, -2, 3, 2};
vector<int> res;
long long read() {
  long long x;
  cin >> x;
  return x;
}
long long graderCross(int i, int j, int k) {
  long long xa = x[j] - x[i], ya = y[j] - y[i];
  long long xb = x[k] - x[i], yb = y[k] - y[i];
  return xa * yb - xb * ya;
}
long long graderArea(int i, int j, int k) {
  long long a = (x[i] * y[j] + x[j] * y[k] + x[k] * y[i]);
  long long b = (y[i] * x[j] + y[j] * x[k] + y[k] * x[i]);
  return a - b;
}
long long askArea(int i, int j, int k) {
  cout << "1 " << i << ' ' << j << ' ' << k << '\n';
  cout.flush();
  long long rep = read();
  return rep;
}
long long askCross(int i, int j, int k) {
  cout << "2 " << i << ' ' << j << ' ' << k << '\n';
  cout.flush();
  long long rep = read();
  return rep;
}
void output() {
  cout << "0 ";
  for (int i : res) cout << i << ' ';
  cout << '\n';
  cout.flush();
}
int main() {
  cin >> n;
  vector<pair<long long, long long> > a, b;
  long long maxa = 0, maxb = 0;
  int aa, bb;
  for (int i = 3; i <= n; i++) {
    long long dist = abs(askArea(1, 2, i));
    if (askCross(1, 2, i) > 0) {
      if (dist > maxa) maxa = dist, aa = i;
      a.push_back({dist, i});
    } else {
      if (dist > maxb) maxb = dist, bb = i;
      b.push_back({dist, i});
    }
  }
  vector<pair<long long, long long> > a1, a2, b1, b2;
  for (auto i : a) {
    if (i.second == aa) continue;
    if (askCross(aa, 1, i.second) < 0)
      a2.push_back(i);
    else
      a1.push_back(i);
  }
  for (auto i : b) {
    if (i.second == bb) continue;
    if (askCross(bb, 2, i.second) < 0)
      b2.push_back(i);
    else
      b1.push_back(i);
  }
  sort(a1.begin(), a1.end());
  sort(a2.rbegin(), a2.rend());
  sort(b1.begin(), b1.end());
  sort(b2.rbegin(), b2.rend());
  res.push_back(1);
  if (!b.empty()) {
    for (auto i : b1) res.push_back(i.second);
    res.push_back(bb);
    for (auto i : b2) res.push_back(i.second);
  }
  res.push_back(2);
  if (!a.empty()) {
    for (auto i : a1) res.push_back(i.second);
    res.push_back(aa);
    for (auto i : a2) res.push_back(i.second);
  }
  output();
  return 0;
}
