#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
struct pii {
  long long val;
  int id;
};
bool operator<(const pii &a, const pii &b) {
  if (a.val == b.val) return a.id < b.id;
  return a.val < b.val;
}
pii vep[10010];
pii ven[10010];
int cntp = 0;
int cntn = 0;
int maxp = 0;
int maxn = 0;
pii vepp[10010];
pii vepn[10010];
int cntpp = 0;
int cntpn = 0;
pii venp[10010];
pii venn[10010];
int cntnp = 0;
int cntnn = 0;
int main() {
  int n;
  cin >> n;
  for (int i = 3; i <= n; i++) {
    int flag;
    long long area;
    printf("1 %d %d %d\n", 1, 2, i);
    fflush(stdout);
    cin >> area;
    printf("2 %d %d %d\n", 1, 2, i);
    fflush(stdout);
    cin >> flag;
    if (flag > 0)
      vep[cntp++] = pii{area, i};
    else
      ven[cntn++] = pii{area, i};
  }
  if (cntp) {
    for (int i = 0; i < cntp; i++)
      if (vep[i].val > vep[maxp].val) maxp = i;
    for (int i = 0; i < cntp; i++) {
      if (i == maxp) continue;
      printf("2 %d %d %d\n", 1, vep[maxp].id, vep[i].id);
      fflush(stdout);
      int flag;
      cin >> flag;
      if (flag > 0)
        vepp[cntpp++] = vep[i];
      else
        vepn[cntpn++] = vep[i];
    }
  }
  if (cntn) {
    for (int i = 0; i < cntn; i++)
      if (ven[i].val > ven[maxn].val) maxn = i;
    for (int i = 0; i < cntn; i++) {
      if (i == maxn) continue;
      printf("2 %d %d %d\n", 1, ven[maxn].id, ven[i].id);
      fflush(stdout);
      int flag;
      cin >> flag;
      if (flag > 0)
        venp[cntnp++] = ven[i];
      else
        venn[cntnn++] = ven[i];
    }
  }
  if (cntpp) sort(vepp, vepp + cntpp);
  if (cntpn) sort(vepn, vepn + cntpn);
  if (cntnp) sort(venp, venp + cntnp);
  if (cntnn) sort(venn, venn + cntnn);
  cout << "0 1";
  if (cntn) {
    for (int i = 0; i < cntnn; i++) cout << " " << venn[i].id;
    cout << " " << ven[maxn].id;
    for (int i = cntnp - 1; i >= 0; i--) cout << " " << venp[i].id;
  }
  cout << " 2";
  if (cntp) {
    for (int i = 0; i < cntpn; i++) cout << " " << vepn[i].id;
    cout << " " << vep[maxp].id;
    for (int i = cntpp - 1; i >= 0; i--) cout << " " << vepp[i].id;
  }
  cout << endl;
  return 0;
}
