#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > p[100001];
int main() {
  int n;
  scanf("%d", &n);
  int row[n], col[n];
  memset(row, 0, sizeof(row));
  memset(col, 0, sizeof(col));
  int arr[n][n];
  memset(arr, 0, sizeof(arr));
  int x, y;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d %d", &x, &y);
    x--;
    y--;
    row[x]++;
    col[y]++;
    arr[x][y] = 1;
  }
  int mark, index = 0;
  for (int i = n - 1; i >= 0; i--) {
    mark = i;
    for (int j = i; j >= 0; j--)
      if (row[j] > row[mark]) mark = j;
    if (mark != i) {
      p[index++] = make_pair(1, make_pair(mark + 1, i + 1));
      swap(row[i], row[mark]);
      for (int k = 0; k < n; k++) {
        swap(arr[i][k], arr[mark][k]);
      }
    }
  }
  int base = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= n - 1; j++) {
      if (arr[i][j] == 1) {
        if (base < j) {
          p[index++] = make_pair(2, make_pair(base + 1, j + 1));
          swap(col[j], col[base]);
          for (int k = 0; k < n; k++) {
            swap(arr[k][j], arr[k][base]);
          }
        }
        base++;
      }
    }
  }
  printf("%d\n", index);
  for (int i = 0; i < index; i++) {
    printf("%d %d %d\n", p[i].first, p[i].second.first, p[i].second.second);
  }
}
