#include <bits/stdc++.h>
using namespace std;
bool T[1001][1001];
int n, x, y;
int I[1001], J[1001];
vector<pair<int, pair<int, int> > > Res;
bool has1col(int j) {
  for (int i = 0; i < n; ++i)
    if (T[I[i]][J[j]]) return 1;
  return 0;
}
bool has1row(int i) {
  for (int j = 0; j < n; ++j)
    if (T[I[i]][J[j]]) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    T[x - 1][y - 1] = 1;
  }
  for (int i = 0; i < n; ++i) I[i] = J[i] = i;
  while (n > 1) {
    for (int j = 0; j < n - 1; ++j)
      if (!has1col(j)) {
        swap(J[n - 1], J[j]);
        Res.push_back(make_pair(2, make_pair(j + 1, n)));
        break;
      }
    for (int i = 0; i < n - 1; ++i)
      if (has1row(i)) {
        swap(I[n - 1], I[i]);
        Res.push_back(make_pair(1, make_pair(i + 1, n)));
        break;
      }
    --n;
  }
  cout << Res.size() << "\n";
  for (int i = 0; i < Res.size(); ++i)
    cout << Res[i].first << " " << Res[i].second.first << " "
         << Res[i].second.second << "\n";
}
