#include <bits/stdc++.h>
using namespace std;
long long ask(long long t, long long i, long long j, long long k) {
  cout << t << " " << i << " " << j << " " << k << endl;
  long long resp;
  cin >> resp;
  return resp;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<pair<long long, long long>> v[2];
  for (int i = 2, ggdem = n; i < ggdem; ++i) {
    v[ask(2, 1, 2, i + 1) == -1].push_back({ask(1, 1, 2, i + 1), i});
  }
  deque<long long> d[2];
  for (int k = 0, ggdem = 2; k < ggdem; ++k) {
    sort(v[k].begin(), v[k].end());
    reverse(v[k].begin(), v[k].end());
    if (((int)v[k].size())) d[k].push_back(v[k][0].second + 1);
    for (int i = 0, ggdem = ((int)v[k].size()) - 1; i < ggdem; ++i) {
      if (ask(2, 1 + k, v[k][i].second + 1, v[k][i + 1].second + 1) == 1)
        d[k].push_front(v[k][i + 1].second + 1);
      else
        d[k].push_back(v[k][i + 1].second + 1);
    }
  }
  vector<long long> res;
  for (auto i : d[0]) res.push_back(i);
  res.push_back(2);
  for (auto i : d[1]) res.push_back(i);
  res.push_back(1);
  reverse(res.begin(), res.end());
  cout << 0 << " ";
  for (auto i : res) cout << i << " ";
  return 0;
}
