#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, long long> a, pair<int, long long> b) {
  return a.second > b.second;
}
int n;
long long getArea(int i, int j, int k) {
  cout << 1 << " " << i << " " << j << " " << k << endl;
  cout.flush();
  long long ret;
  cin >> ret;
  return ret;
}
int getSign(int i, int j, int k) {
  cout << 2 << " " << i << " " << j << " " << k << endl;
  cout.flush();
  int ret;
  cin >> ret;
  return ret;
}
int getRandom(int n) {
  srand(time(0));
  return rand() % (n - 1) + 2;
}
vector<long long> area;
bool cmp0(int a, int b) { return area[a] < area[b]; }
bool cmp1(int a, int b) { return area[a] > area[b]; }
void work() {
  cin >> n;
  int nxt = 2;
  for (int i = 3; i <= n; ++i) {
    if (getSign(1, nxt, i) < 0) nxt = i;
  }
  int far = -1;
  for (int i = 0; i <= n; ++i) area.push_back(0);
  for (int i = 2; i <= n; ++i) {
    if (i == nxt) continue;
    area[i] = getArea(1, nxt, i);
    if (far == -1 || area[far] < area[i]) far = i;
  }
  vector<int> group[2];
  for (int i = 2; i <= n; ++i) {
    if (i == nxt || i == far) continue;
    if (getSign(1, far, i) < 0)
      group[0].push_back(i);
    else
      group[1].push_back(i);
  }
  sort(group[0].begin(), group[0].end(), cmp0);
  sort(group[1].begin(), group[1].end(), cmp1);
  cout << "0 " << 1 << " " << nxt << " ";
  for (int i = 0; i < group[0].size(); ++i) cout << group[0][i] << " ";
  cout << far << " ";
  for (int i = 0; i < group[1].size(); ++i) cout << group[1][i] << " ";
}
int main() { work(); }
