#include <bits/stdc++.h>
using namespace std;
struct pp {
  int t, x, y;
} aa[1000000];
pair<int, int> a[1010];
int main() {
  int n;
  cin >> n;
  int ct = 0;
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[i].first = x, a[i].second = y;
  }
  for (int i = 1; i < n; i++) {
    int x = a[i].first, y = a[i].second;
    if (x != i + 1) {
      for (int j = i + 1; j < n; j++) {
        if (a[j].first == i + 1)
          a[j].first = x;
        else if (a[j].first == a[i].first)
          a[j].first = i + 1;
      }
      aa[ct].t = 1;
      aa[ct].x = a[i].first;
      aa[ct].y = i + 1;
      ct++;
    }
    if (a[i].second > i) {
      for (int j = i + 1; j < n; j++) {
        if (a[j].second == i)
          a[j].second = a[i].second;
        else if (a[j].second == a[i].second)
          a[j].second = i;
      }
      aa[ct].t = 2;
      aa[ct].x = a[i].second;
      aa[ct++].y = i;
    }
  }
  cout << ct << endl;
  for (int i = 0; i < ct; i++)
    cout << aa[i].t << " " << aa[i].x << " " << aa[i].y << endl;
}
