#include <bits/stdc++.h>
long long srf(int a, int b, int c) {
  std::cout << "1 " << (a + 1) << ' ' << (b + 1) << ' ' << (c + 1) << std::endl;
  long long val;
  std::cin >> val;
  return val;
}
bool scl(int a, int b, int c) {
  std::cout << "2 " << (a + 1) << ' ' << (b + 1) << ' ' << (c + 1) << std::endl;
  int val;
  std::cin >> val;
  return val > 0;
}
void accept(std::vector<int> ans) {
  std::cout << "0 ";
  for (int i : ans) {
    std::cout << (i + 1) << ' ';
  }
  std::cout << std::endl;
  return;
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  int n;
  std::cin >> n;
  std::vector<int> ans(n);
  std::iota(ans.begin(), ans.end(), 0);
  int pos =
      std::min_element(ans.begin() + 1, ans.end(),
                       [&ans](int f, int s) { return scl(ans[0], f, s); }) -
      ans.begin();
  std::swap(ans[1], ans[pos]);
  std::map<int, long long> map;
  for (int i = 2; i < n; i++) {
    map[ans[i]] = srf(ans[0], ans[1], ans[i]);
  }
  pos = std::max_element(ans.begin() + 1, ans.end(),
                         [&map](int f, int s) { return map[f] < map[s]; }) -
        ans.begin();
  std::swap(ans.back(), ans[pos]);
  std::vector<int> left, right;
  for (int i = 2; i < (ans.size() - 1); i++) {
    if (scl(ans[0], ans.back(), ans[i])) {
      left.push_back(ans[i]);
    } else {
      right.push_back(ans[i]);
    }
  }
  std::vector<int> ans2 = {ans[0], ans[1]};
  std::sort(right.begin(), right.end(),
            [&map](int f, int s) { return map[f] < map[s]; });
  for (int i : right) {
    ans2.push_back(i);
  }
  ans2.push_back(ans.back());
  std::sort(left.begin(), left.end(),
            [&map](int f, int s) { return map[f] < map[s]; });
  std::reverse(left.begin(), left.end());
  for (int i : left) {
    ans2.push_back(i);
  }
  accept(ans2);
  return 0;
}
