#include <bits/stdc++.h>
using namespace std;
int n;
int row[1005], col[1005], H[1005];
vector<pair<int, pair<int, int> > > A;
vector<pair<int, int> > P;
int main() {
  while (cin >> n) {
    A.clear();
    P.clear();
    int u, v;
    for (int i = 0; i < n - 1; i++) {
      scanf("%d %d", &u, &v);
      row[u]++;
      col[v]++;
      P.push_back(make_pair(u, v));
    }
    int ans = 0;
    for (int i = n; i > 0; i--) {
      int j = max_element(row + 1, row + i + 1) - row;
      if (row[j] != row[i]) {
        ans++;
        A.push_back(make_pair(1, make_pair(i, j)));
        swap(row[j], row[i]);
        for (int k = 0; k < P.size(); k++) {
          if (P[k].first == i)
            P[k].first = j;
          else if (P[k].first == j)
            P[k].first = i;
        }
      }
    }
    memset(H, 0x3f, sizeof H);
    for (int i = 0; i < P.size(); i++) {
      if (P[i].first < H[P[i].second]) H[P[i].second] = P[i].first;
    }
    for (int i = 1; i <= n; i++) {
      int t = min_element(H + i, H + n + 1) - H;
      if (H[t] != H[i]) {
        ans++;
        A.push_back(make_pair(2, make_pair(i, t)));
        swap(H[i], H[t]);
      }
    }
    cout << ans << endl;
    for (int i = 0; i < A.size(); i++) {
      printf("%d %d %d\n", A[i].first, A[i].second.first, A[i].second.second);
    }
  }
  return 0;
}
