#include <bits/stdc++.h>
using namespace std;
int arr[1009][1009];
int ans = 0;
int ansm[100009][3];
void solve(int size) {
  if (size == 1) return;
  int empty_col;
  for (int j = 0; j < size; j++) {
    bool flag = true;
    for (int i = 0; i < size; i++) {
      if (arr[i][j] == 1) {
        flag = false;
        break;
      }
    }
    if (flag) {
      empty_col = j;
      break;
    }
  }
  if (empty_col != size - 1) {
    ansm[ans][0] = 2;
    ansm[ans][1] = empty_col + 1;
    ansm[ans][2] = size;
    ans++;
    for (int i = 0; i < size; i++) swap(arr[i][empty_col], arr[i][size - 1]);
  }
  int occ_row;
  for (int i = 0; i < size; i++) {
    bool flag = false;
    for (int j = 0; j < size; j++) {
      if (arr[i][j] == 1) {
        flag = true;
        break;
      }
    }
    if (flag) {
      occ_row = i;
      break;
    }
  }
  if (occ_row != size - 1) {
    ansm[ans][0] = 1;
    ansm[ans][1] = occ_row + 1;
    ansm[ans][2] = size;
    ans++;
    for (int j = 0; j < size; j++) swap(arr[occ_row][j], arr[size - 1][j]);
  }
  solve(size - 1);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    arr[x - 1][y - 1] = 1;
  }
  solve(n);
  printf("%d\n", ans);
  for (int i = 0; i < ans; i++)
    printf("%d %d %d\n", ansm[i][0], ansm[i][1], ansm[i][2]);
  return 0;
}
