#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> r(n, 0), c(n, 0);
  vector<vector<bool> > v(n, vector<bool>(n, 0));
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    r[a - 1]++;
    c[b - 1]++;
    v[a - 1][b - 1] = 1;
  }
  vector<int> res;
  for (int i = 0; i < n - 1; i++) {
    if (r[i] != 0)
      for (int j = i + 1; j < n; j++) {
        if (r[j] == 0) {
          res.push_back(1);
          res.push_back(i + 1);
          res.push_back(j + 1);
          swap(r[i], r[j]);
          swap(v[i], v[j]);
          break;
        }
      }
    if (c[i] == 0) {
      for (int j = i + 1; j < n; j++) {
        if (c[j] != 0) {
          res.push_back(2);
          res.push_back(i + 1);
          res.push_back(j + 1);
          swap(c[i], c[j]);
          for (int k = i; k < n; k++) {
            swap(v[k][i], v[k][j]);
          }
          break;
        }
      }
    }
    for (int j = i; j < n; j++) {
      r[j] -= v[j][i];
    }
  }
  int s = res.size() / 3;
  cout << s << "\n";
  for (int i = 0; i < s; i++) {
    cout << res[3 * i] << " " << res[3 * i + 1] << " " << res[3 * i + 2]
         << "\n";
  }
}
