#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
struct node {
  int op, x, y;
} ans[2 * N];
int a[N][N];
int main() {
  int n, x, y, m, num = 0;
  scanf("%d", &n);
  m = n;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    a[x][y] = 1;
  }
  while (m > 1) {
    int cnt, pos = 0;
    for (int j = 1; j <= m; j++) {
      cnt = 0;
      for (int i = 1; i <= m; i++) cnt += a[i][j];
      if (!cnt) {
        pos = j;
        break;
      }
    }
    if (pos != m && pos) ans[++num] = (node){2, pos, m};
    for (int i = 1; i <= m; i++) swap(a[i][pos], a[i][m]);
    pos = 0;
    for (int i = 1; i <= m; i++) {
      cnt = 0;
      for (int j = 1; j <= m; j++) cnt += a[i][j];
      if (cnt) {
        pos = i;
        break;
      }
    }
    if (pos != m && pos) ans[++num] = (node){1, pos, m};
    for (int j = 1; j <= m; j++) swap(a[pos][j], a[m][j]);
    m--;
  }
  printf("%d\n", num);
  for (int i = 1; i <= num; i++)
    printf("%d %d %d\n", ans[i].op, ans[i].x, ans[i].y);
  return 0;
}
