#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  deque<long long> NW, NE, SW, SE;
  long long W = 1, E = 2, S = -1, N = -1;
  deque<pair<long long, long long> > north, south;
  for (long long i = (long long)3; i <= (long long)n; i++) {
    long long height, direction;
    cout << 1 << " " << 1 << " " << 2 << " " << i << '\n';
    fflush(stdout);
    cin >> height;
    cout << 2 << " " << 1 << " " << 2 << " " << i << '\n';
    fflush(stdout);
    cin >> direction;
    if (direction == 1)
      north.push_back(make_pair(height, i));
    else
      south.push_back(make_pair(height, i));
  }
  sort(north.begin(), north.end());
  sort(south.begin(), south.end());
  if (!north.empty()) N = north[int(north.size()) - 1].second;
  if (!south.empty()) S = south[int(south.size()) - 1].second;
  for (long long i = (long long)int(north.size()) - 2; i >= (long long)0; i--) {
    long long direction;
    cout << 2 << " " << 1 << " " << N << " " << north[i].second << '\n';
    fflush(stdout);
    cin >> direction;
    if (direction == 1)
      NW.push_back(north[i].second);
    else
      NE.push_front(north[i].second);
  }
  for (long long i = (long long)int(south.size()) - 2; i >= (long long)0; i--) {
    long long direction;
    cout << 2 << " " << 1 << " " << S << " " << south[i].second << '\n';
    fflush(stdout);
    cin >> direction;
    if (direction == 1)
      SE.push_back(south[i].second);
    else
      SW.push_front(south[i].second);
  }
  cout << "0 1 ";
  for (long long i = (long long)0; i <= (long long)int(SW.size()) - 1; i++)
    cout << SW[i] << " ";
  if (S != -1) cout << S << " ";
  for (long long i = (long long)0; i <= (long long)int(SE.size()) - 1; i++)
    cout << SE[i] << " ";
  cout << "2 ";
  for (long long i = (long long)0; i <= (long long)int(NE.size()) - 1; i++)
    cout << NE[i] << " ";
  if (N != -1) cout << N << " ";
  for (long long i = (long long)0; i <= (long long)int(NW.size()) - 1; i++)
    cout << NW[i] << " ";
  cout << '\n';
  fflush(stdout);
  return 0;
}
