#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n + 5][n + 5], a, b;
  map<int, int> mp, mp2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      arr[i][j] = 0;
    }
  }
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    arr[a][b] = 1;
    mp[a]++;
    mp2[b]++;
  }
  vector<pair<int, pair<int, int>>> v;
  int tmp = n;
  while (tmp > 1) {
    if (mp2[tmp]) {
      for (int i = 1; i < tmp; i++) {
        if (!mp2[i]) {
          v.push_back({2, {i, tmp}});
          mp2[i] = mp2[tmp];
          for (int ii = 1; ii <= tmp; ii++) {
            swap(arr[ii][tmp], arr[ii][i]);
          }
          break;
        }
      }
    }
    if (!mp[tmp]) {
      for (int i = 1; i < tmp; i++) {
        if (mp[i]) {
          v.push_back({1, {i, tmp}});
          mp[i] = mp[tmp];
          for (int ii = 1; ii <= tmp; ii++) {
            mp2[ii] -= arr[i][ii];
            swap(arr[tmp][ii], arr[i][ii]);
          }
          break;
        }
      }
    } else {
      for (int ii = 1; ii <= tmp; ii++) {
        mp2[ii] -= arr[tmp][ii];
        arr[tmp][ii] = 0;
      }
    }
    tmp--;
  }
  cout << v.size() << '\n';
  for (auto i : v) {
    cout << i.first << " " << i.second.first << " " << i.second.second << '\n';
  }
  return 0;
}
