#include <bits/stdc++.h>
using namespace std;
int c[1005][1005], a[1005], r[1005];
struct ppp {
  int x, y, v;
};
vector<ppp> ans;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    c[x][y] = 1;
  }
  for (int i = 1; i <= n; i++) {
    int mx = 0;
    for (int j = 1; j <= n; j++) {
      if (c[j][i]) mx = j;
    }
    a[i] = mx;
  }
  for (int i = 1; i <= n; i++) {
    int mx = 0, x = i;
    for (int j = i; j <= n; j++) {
      if (mx < a[j]) mx = a[j], x = j;
    }
    if (x == i) continue;
    ans.push_back({2, i, x});
    swap(a[x], a[i]);
    for (int j = 1; j <= n; j++) {
      swap(c[j][x], c[j][i]);
    }
  }
  for (int i = 1; i <= n; i++) {
    int mx = 0;
    for (int j = 1; j <= n; j++) {
      if (c[i][j]) mx = j;
    }
    r[i] = mx;
  }
  for (int i = 1; i <= n; i++) {
    int mi = 2e9, x = i;
    for (int j = i; j <= n; j++) {
      if (mi > r[j]) mi = r[j], x = j;
    }
    if (x == i) continue;
    ans.push_back({1, i, x});
    swap(r[x], r[i]);
  }
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.x << " " << i.y << " " << i.v << endl;
  }
}
