#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
const double EPS = 1e-9;
int mods(int a, int b) { return (b + (a % b)) % b; }
int n, x, y, cur, total, row[1005], col[1005];
bool mat[1005][1005];
vector<pair<int, pair<int, int> > > ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    mat[x][y] = 1;
    row[x]++;
    col[y]++;
  }
  total = n - 1;
  for (int i = n; i >= 1; i--) {
    if (col[i]) {
      for (int j = 1; j < i; j++) {
        if (!col[j]) {
          ans.push_back(pair<int, pair<int, int> >(2, pair<int, int>(i, j)));
          for (int k = 1; k <= n; k++) swap(mat[k][i], mat[k][j]);
          swap(col[i], col[j]);
          break;
        }
      }
    }
    if (!row[i]) {
      for (int j = 1; j < i; j++) {
        if (row[j]) {
          ans.push_back(pair<int, pair<int, int> >(1, pair<int, int>(i, j)));
          for (int k = 1; k <= n; k++) swap(mat[i][k], mat[j][k]);
          swap(row[i], row[j]);
          break;
        }
      }
    }
    for (int j = 1; j <= n; j++) {
      if (mat[i][j]) {
        col[j]--;
        total--;
        if (total == 0) break;
      }
    }
    if (total == 0) break;
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second.first << " "
         << ans[i].second.second << '\n';
  return 0;
}
