#include <bits/stdc++.h>
int A;
int ans[100000][3] = {0};
int n;
int row[1001][1001] = {0};
int col[1001][1001] = {0};
int R[1001] = {0};
int C[1001] = {0};
int tmp[1001] = {0};
int max, p;
int swap(int mode, int a, int b) {
  if (mode == 2) {
    for (int i = 0; i < C[a]; i++) tmp[col[a][i]] = b;
  } else {
    int x = tmp[a];
    tmp[a] = tmp[b];
    tmp[b] = x;
  }
  if (a == b) return 0;
  ans[A][0] = mode;
  ans[A][1] = a;
  ans[A][2] = b;
  A++;
  return 0;
}
int main() {
  int a, b;
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    row[a][R[a]] = b;
    col[b][C[b]] = a;
    R[a]++;
    C[b]++;
  }
  for (i = 1, j = 1; i <= n; i++) {
    if (C[i] > 0)
      if (i >= j) {
        swap(2, i, j);
        j++;
      }
  }
  for (i = 1; i < n; i++) {
    for (j = 1, max = 0; j <= n - i + 1; j++)
      if (tmp[j] > max) {
        max = tmp[j];
        p = j;
      }
    swap(1, p, n - i + 1);
  }
  printf("%ld\n", A);
  for (i = 0; i < A; i++) printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]);
  return 0;
}
