#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, mx, t, pos;
int h[200001], h2[200001];
int x[200001], y[200001];
int q[200001], w[200001], z[200001];
int a[1001][1001];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) h[i] = 1000000000;
  for (i = 1; i < n; i++) {
    cin >> x[i] >> y[i];
    a[x[i]][y[i]] = 1;
    h[y[i]] = min(h[y[i]], x[i]);
  }
  int mn;
  for (i = 1; i <= n; i++) {
    mn = 1000000000;
    pos = i;
    for (j = i; j <= n; j++)
      if (h[j] < mn) {
        mn = h[j];
        pos = j;
      }
    if (i != pos) {
      swap(h[i], h[pos]);
      for (j = 1; j <= n; j++) swap(a[j][i], a[j][pos]);
      ++t;
      z[t] = 2;
      q[t] = i;
      w[t] = pos;
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (a[i][j]) h2[i] = max(h2[i], j);
  for (i = 1; i <= n; i++) {
    mn = 1000000000;
    pos = i;
    for (j = i; j <= n; j++)
      if (h2[j] < mn) {
        mn = h2[j];
        pos = j;
      }
    if (i != pos) {
      swap(h2[i], h2[pos]);
      ++t;
      z[t] = 1;
      q[t] = i;
      w[t] = pos;
    }
  }
  cout << t << endl;
  for (i = 1; i <= t; i++) {
    cout << z[i] << " " << q[i] << " " << w[i];
    cout << endl;
  }
  return 0;
}
