#include <bits/stdc++.h>
using namespace std;
int n;
int col[1005];
int row[1005];
int last[1005];
bool mt[1005][1005];
vector<int> op, e1, e2;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    row[x]++;
    col[y]++;
    mt[x][y] = 1;
  }
  int m = 0;
  for (int i = 0; i < n; i++) {
    m = i;
    for (int j = i + 1; j < n; j++)
      if (col[j] > col[m]) m = j;
    if (m != i) {
      op.push_back(2);
      e1.push_back(i);
      e2.push_back(m);
      swap(col[i], col[m]);
      for (int j = 0; j < n; j++) swap(mt[j][i], mt[j][m]);
    }
  }
  memset(last, -1, sizeof last);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (mt[i][j]) last[i] = j;
  }
  for (int i = n - 1; i >= 0; i--) {
    int m = i;
    for (int j = i - 1; j >= 0; j--)
      if (last[j] > last[m]) m = j;
    if (m != i) {
      op.push_back(1);
      e1.push_back(i);
      e2.push_back(m);
      swap(last[i], last[m]);
    }
  }
  printf("%d\n", op.size());
  for (int i = 0; i < op.size(); i++)
    printf("%d %d %d\n", op[i], e1[i] + 1, e2[i] + 1);
}
