#include <bits/stdc++.h>
using namespace std;
inline bool ask2(long long f, long long s, long long i) {
  cout << 2 << ' ' << f << ' ' << s << ' ' << i << endl;
  long long t;
  cin >> t;
  if (t == 1)
    return true;
  else
    return false;
}
inline long long get(long long f, long long s, long long i) {
  cout << 1 << ' ' << f << ' ' << s << ' ' << i << endl;
  long long t;
  cin >> t;
  return t;
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> first;
  vector<long long> second;
  long long f = 1, s = 2;
  for (long long i = 3; i <= n; i++) {
    bool t = ask2(f, s, i);
    if (t)
      first.push_back(i);
    else
      second.push_back(i);
  }
  vector<pair<long long, long long> > ff, ss;
  for (long long i = 0; i < first.size(); i++) {
    long long S = get(f, s, first[i]);
    ff.emplace_back(S, first[i]);
  }
  for (long long i = 0; i < second.size(); i++) {
    long long S = get(f, s, second[i]);
    ss.emplace_back(S, second[i]);
  }
  sort(ff.begin(), ff.end());
  sort(ss.begin(), ss.end());
  vector<long long> up(ff.size());
  vector<long long> down(ss.size());
  long long l = 0, r = ff.size() - 1;
  for (long long i = 0; i < ff.size(); i++) {
    if (i == ff.size() - 1) {
      up[l] = ff.back().second;
      break;
    }
    bool fe = ask2(f, ff.back().second, ff[i].second);
    if (fe) {
      up[l] = ff[i].second;
      l++;
    } else {
      up[r] = ff[i].second;
      r--;
    }
  }
  l = 0, r = ss.size() - 1;
  for (long long i = 0; i < ss.size(); i++) {
    if (i == ss.size() - 1) {
      down[l] = ss.back().second;
      break;
    }
    bool fe = ask2(f, ss.back().second, ss[i].second);
    if (!fe) {
      down[l] = ss[i].second;
      l++;
    } else {
      down[r] = ss[i].second;
      r--;
    }
  }
  cout << 0 << ' ';
  cout << 1 << ' ';
  for (auto x : down) cout << x << ' ';
  cout << 2 << ' ';
  reverse(up.begin(), up.end());
  for (auto x : up) cout << x << ' ';
}
