#include <bits/stdc++.h>
using namespace std;
struct point_t {
  int x, y;
};
int main() {
  int n;
  cin >> n;
  point_t ones[n - 1];
  int mrows[n], mcols[n], rmcols[n];
  int crows[n], ccols[n];
  for (int i = 0; i < n; i++) {
    mrows[i] = mcols[i] = i;
    crows[i] = ccols[i] = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> ones[i].x >> ones[i].y;
    ones[i].x--, ones[i].y--;
    crows[ones[i].x]++;
    ccols[ones[i].y]++;
  }
  vector<pair<int, int>> rowswap, colswap;
  for (int index = 0; index < n; index++) {
    for (int i = index; i < n; i++) {
      if (crows[mrows[i]] == 0) {
        swap(mrows[i], mrows[index]);
        if (i != index) rowswap.push_back(make_pair(i, index));
        break;
      }
    }
    int maxcol_idx = index;
    for (int j = index; j < n; j++) {
      if (ccols[mcols[j]] > ccols[mcols[maxcol_idx]]) {
        maxcol_idx = j;
      }
    }
    swap(mcols[maxcol_idx], mcols[index]);
    if (maxcol_idx != index) colswap.push_back(make_pair(maxcol_idx, index));
    for (int i = 0; i < n; i++) rmcols[mcols[i]] = i;
    for (int i = 0; i < n - 1; i++)
      if (rmcols[ones[i].y] == index) crows[ones[i].x]--;
  }
  cout << rowswap.size() + colswap.size() << endl;
  for (int i = 0; i < rowswap.size(); i++)
    cout << 1 << ' ' << rowswap[i].first + 1 << ' ' << rowswap[i].second + 1
         << endl;
  for (int i = 0; i < colswap.size(); i++)
    cout << 2 << ' ' << colswap[i].first + 1 << ' ' << colswap[i].second + 1
         << endl;
}
