#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long inf = 1ll << 62;
const int iinf = 0x7fffffff;
long long powmod(long long a, long long b) {
  long long ans;
  while (b) {
    if (b & 1) {
      ans *= a;
      ans %= mod;
    }
    b >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; };
int n;
long long query_one(int a, int b, int c) {
  long long ans;
  cout << 1 << " " << a << " " << b << " " << c << endl;
  cout.flush();
  cin >> ans;
  return ans;
}
int query_two(int a, int b, int c) {
  int ans;
  cout << 2 << " " << a << " " << b << " " << c << endl;
  cout.flush();
  cin >> ans;
  return ans;
}
bool cmp(pair<long long, int> a, pair<long long, int> b) {
  if (a.first != b.first)
    return a.first < b.first;
  else {
    return a.second < b.second;
  }
}
vector<int> get_ans(int a, int b, vector<int> c) {
  vector<pair<long long, int> > area_id;
  for (int i : c) {
    pair<long long, int> temp(query_one(a, b, i), i);
    area_id.push_back(temp);
  }
  sort(area_id.begin(), area_id.end(), cmp);
  int mid = area_id.back().second;
  vector<int> left, right;
  for (auto i : area_id) {
    int s = i.second;
    if (s == mid || query_two(b, mid, s) == -1)
      left.push_back(s);
    else
      right.push_back(s);
  }
  while (!right.empty()) {
    left.push_back(right.back());
    right.pop_back();
  }
  return left;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<int> left;
  vector<int> right;
  for (int(i) = (3); (i) < (n + 1); (i)++) {
    if (query_two(1, 2, i) == 1)
      left.push_back(i);
    else
      right.push_back(i);
  }
  vector<int> ans_f = get_ans(1, 2, left);
  vector<int> ans_s = get_ans(2, 1, right);
  cout << 0 << " " << 1;
  for (auto i : ans_s) cout << " " << i;
  cout << " " << 2;
  for (auto i : ans_f) cout << " " << i;
  cout.flush();
  return 0;
}
