#include <bits/stdc++.h>
using namespace std;
int n, mat[1009][1009];
vector<pair<int, pair<int, int> > > ans;
void perform(int k) {
  if (k == 1) return;
  int ind;
  for (int j = 1; j <= k; j++) {
    int flag = 0;
    for (int i = 1; i <= k; i++) {
      if (mat[i][j]) flag = 1;
    }
    if (!flag) ind = j;
  }
  if (ind != k) {
    ans.push_back({2, {ind, k}});
    for (int i = 1; i <= k; i++) {
      int temp = mat[i][ind];
      mat[i][ind] = mat[i][k];
      mat[i][k] = temp;
    }
  }
  for (int i = 1; i <= k; i++) {
    int flag = 0;
    for (int j = 1; j <= k; j++) {
      if (mat[i][j]) flag = 1;
    }
    if (flag) {
      ind = i;
    }
  }
  if (ind != k) {
    ans.push_back({1, {ind, k}});
    for (int i = 1; i <= k; i++) {
      int temp = mat[ind][i];
      mat[ind][i] = mat[k][i];
      mat[k][i] = temp;
    }
  }
  k--;
  perform(k);
}
int main() {
  cin >> n;
  int i = 0;
  while (i < n - 1) {
    int a, b;
    cin >> a >> b;
    mat[a][b] = 1;
    i++;
  }
  perform(n);
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.first << " " << i.second.first << " " << i.second.second << endl;
  }
}
