#include <bits/stdc++.h>
using namespace std;
int n, col[1102], row[1102], x, y, top = 0;
int A[1102][1102], idC[1102], idR[1102];
int ans[100010][3];
void solve(int n, int rem) {
  if (!rem || n == 1) return;
  int c, d;
  for (c = 0; c < n; c++)
    if (!col[idC[c]]) break;
  for (d = 0; d < n; d++)
    if (row[idR[d]]) break;
  swap(idC[c], idC[n - 1]);
  for (int i = 0; i < n; i++)
    if (A[idR[d]][idC[i]] == 1) col[idC[i]]--;
  swap(idR[d], idR[n - 1]);
  if (c != n - 1) {
    ans[top][0] = 2;
    ans[top][1] = c + 1;
    ans[top++][2] = n;
  }
  if (d != n - 1) {
    ans[top][0] = 1;
    ans[top][1] = d + 1;
    ans[top++][2] = n;
  }
  solve(n - 1, rem - row[idR[n - 1]]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    A[x - 1][y - 1] = 1;
    col[y - 1]++, row[x - 1]++;
  }
  for (int i = 0; i < n; i++) idC[i] = i, idR[i] = i;
  solve(n, n - 1);
  printf("%d\n", top);
  for (int i = 0; i < top; i++)
    printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]);
  return 0;
}
