#include <bits/stdc++.h>
using namespace std;
const int MN = 100005, inf = 1000000005, mod = 1000000007;
const long long INF = 1000000000000000005LL;
inline bool lewa(int a, int b, int c) {
  if (a == b || a == c || b == c) return false;
  printf("2 %d %d %d\n", a, b, c);
  fflush(stdout);
  int ans;
  scanf("%d", &ans);
  return (ans > 0);
}
inline long long pole(int a, int b, int c) {
  if (a == b || a == c || b == c) return 0LL;
  printf("1 %d %d %d\n", a, b, c);
  fflush(stdout);
  long long ans;
  scanf("%lld", &ans);
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<long long, int> > L, P, LA, LB, PA, PB;
  for (int i = 3; i <= n; ++i) {
    long long p = pole(1, 2, i);
    if (lewa(1, 2, i))
      L.push_back({p, i});
    else
      P.push_back({p, i});
  }
  pair<long long, int> mx;
  mx = {-1, -1};
  for (auto p : P) mx = max(mx, p);
  for (auto p : P)
    if (lewa(1, mx.second, p.second))
      PA.push_back(p);
    else
      PB.push_back(p);
  mx = {-1, -1};
  for (auto p : L) mx = max(mx, p);
  for (auto p : L)
    if (lewa(1, mx.second, p.second))
      LA.push_back(p);
    else
      LB.push_back(p);
  sort((PB).begin(), (PB).end());
  sort((PA).begin(), (PA).end());
  reverse((PA).begin(), (PA).end());
  sort((LB).begin(), (LB).end());
  sort((LA).begin(), (LA).end());
  reverse((LA).begin(), (LA).end());
  printf("0 1 ");
  for (auto p : PB) printf("%d ", p.second);
  for (auto p : PA) printf("%d ", p.second);
  printf("2 ");
  for (auto p : LB) printf("%d ", p.second);
  for (auto p : LA) printf("%d ", p.second);
}
