#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f ? x : -x;
}
const long long N = 1005;
struct node {
  long long t, x, y;
};
long long n, mp[N][N];
vector<node> ans;
void solve(long long n) {
  if (!n) return;
  for (long long j = n; j >= 1; j--) {
    bool f = 1;
    for (long long i = 1; i <= n; i++) {
      if (mp[i][j]) {
        f = 0;
        break;
      }
    }
    if (f && j != n) {
      for (long long i = 1; i <= n; i++) swap(mp[i][j], mp[i][n]);
      ans.push_back({2, j, n});
      break;
    }
    if (f && j == n) break;
  }
  for (long long i = n; i >= 1; i--) {
    bool f = 0;
    for (long long j = 1; j <= n; j++) {
      if (mp[i][j]) {
        f = 1;
        break;
      }
    }
    if (f && i != n) {
      for (long long j = 1; j <= n; j++) swap(mp[i][j], mp[n][j]);
      ans.push_back({1, i, n});
      break;
    }
    if (f && i == n) break;
  }
  solve(n - 1);
}
signed main() {
  n = read();
  for (long long i = 1; i < n; i++) mp[read()][read()] = 1;
  solve(n);
  printf("%lu\n", ans.size());
  for (auto it : ans) printf("%lld %lld %lld\n", it.t, it.x, it.y);
  return 0;
}
