#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace ::std;
const long long maxn = 1e5 + 500;
const long long inf = 1e9 + 800;
const long long mod = 1e9 + 7;
long long getarea(long long i, long long j, long long k) {
  i++;
  j++;
  k++;
  cout << 1 << ' ' << i << ' ' << j << ' ' << k << endl;
  long long ans;
  cin >> ans;
  return ans;
}
long long getsing(long long i, long long j, long long k) {
  i++;
  j++;
  k++;
  cout << 2 << ' ' << i << ' ' << j << ' ' << k << endl;
  long long ans;
  cin >> ans;
  return ans;
}
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > vec;
  vec.push_back(make_pair(0, 0));
  vec.push_back(make_pair(0, 1));
  for (long long i = 2; i < n; i++) {
    vec.push_back(make_pair(getarea(0, 1, i) * getsing(0, 1, i), i));
  }
  sort(vec.begin(), vec.end());
  deque<long long> ans;
  ans.push_back(vec[0].second);
  ans.push_back(vec[1].second);
  for (long long i = 2; i < n; i++) {
    long long v = vec[i].second;
    long long last1 = ans[ans.size() - 1];
    long long last2 = ans[ans.size() - 2];
    if (getsing(last2, last1, v) == 1) {
      ans.push_back(v);
    } else {
      ans.pop_back();
      ans.push_front(last1);
      ans.push_back(v);
    }
  }
  cout << 0 << ' ';
  while (ans[0] != 0) {
    ans.push_back(ans[0]);
    ans.pop_front();
  }
  for (auto v : ans) {
    cout << v + 1 << ' ';
  }
  cout << endl;
}
