#include <bits/stdc++.h>
using namespace std;
const int max_n = 1111;
int n, r[max_n], c[max_n];
vector<pair<int, int> > sol_row, sol_col;
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> r[i] >> c[i];
    r[i]--, c[i]--;
  }
  for (int col = 0; col < n - 1; col++) {
    int idx = -1, mini = n;
    for (int i = 0; i < n - 1; i++)
      if (c[i] >= col && r[i] < mini) mini = r[i], idx = c[i];
    if (idx == -1) break;
    for (int i = 0; i < n - 1; i++)
      if (c[i] == idx)
        c[i] = col;
      else if (c[i] == col)
        c[i] = idx;
    if (idx != col) sol_col.push_back(make_pair(idx + 1, col + 1));
  }
  for (int row = n - 1; row > 0; row--) {
    int idx = -1, maxi = -1;
    for (int i = 0; i < n - 1; i++)
      if (r[i] <= row && c[i] > maxi) maxi = c[i], idx = r[i];
    if (idx == -1) break;
    for (int i = 0; i < n - 1; i++)
      if (r[i] == idx)
        r[i] = row;
      else if (r[i] == row)
        r[i] = idx;
    if (idx != row) sol_row.push_back(make_pair(idx + 1, row + 1));
  }
  cout << sol_row.size() + sol_col.size() << endl;
  for (int i = 0; i < sol_col.size(); i++)
    cout << "2 " << sol_col[i].first << " " << sol_col[i].second << endl;
  for (int i = 0; i < sol_row.size(); i++)
    cout << "1 " << sol_row[i].first << " " << sol_row[i].second << endl;
  return 0;
}
