#include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
void smax(P &a, Q b) {
  if (b > a) a = b;
}
template <class P, class Q>
bool in(const P &a, const Q &b) {
  return a.find(b) != a.end();
}
const int MAXN = 1024;
int n, row[MAXN], col[MAXN];
pair<int, int> pt[MAXN];
vector<int> tp, from, to;
int main() {
  cin >> n;
  for (int i = (1); i < int(n); ++i) {
    cin >> pt[i].first >> pt[i].second;
    pt[i].first--;
    row[pt[i].first]++;
    pt[i].second--;
    col[pt[i].second]++;
  }
  for (int beg = (0); beg < int(n); ++beg) {
    int max_col = beg, min_row = beg;
    for (int i = (beg); i < int(n); ++i) {
      if (col[i] > col[max_col]) max_col = i;
      if (row[i] < row[min_row]) min_row = i;
    }
    for (int i = (1); i < int(n); ++i) {
      if (pt[i].first == min_row)
        pt[i].first = beg;
      else if (pt[i].first == beg)
        pt[i].first = min_row;
      if (pt[i].second == max_col)
        pt[i].second = beg;
      else if (pt[i].second == beg)
        pt[i].second = max_col;
    }
    if (beg != min_row)
      tp.push_back(1), from.push_back(beg), to.push_back(min_row),
          swap(row[beg], row[min_row]);
    if (beg != max_col)
      tp.push_back(2), from.push_back(beg), to.push_back(max_col),
          swap(col[beg], col[max_col]);
    for (int i = (1); i < int(n); ++i)
      if (pt[i].first == beg || pt[i].second == beg)
        row[pt[i].first]--, col[pt[i].second]--;
  }
  cout << ((int)(tp).size()) << endl;
  for (int i = (0); i < int(((int)(tp).size())); ++i)
    cout << tp[i] << " " << from[i] + 1 << " " << to[i] + 1 << endl;
  return 0;
}
