#include <bits/stdc++.h>
using namespace std;
int n;
int grid[1005][1005];
int row[1005], col[1005];
vector<pair<int, pair<int, int> > > output;
void swap_col(int a, int b) {
  for (int i = 1; i <= n; i++) swap(grid[i][a], grid[i][b]);
}
void swap_row(int a, int b) {
  for (int i = 1; i <= n; i++) swap(grid[a][i], grid[b][i]);
}
int main() {
  scanf("%d", &n);
  int check = 1;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    grid[a][b] = 1;
    if (a < b) check = 0;
  }
  if (check) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) row[i] += grid[i][j];
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= n; i++) col[i] += grid[j][i];
  for (int i = n; i > 1; i--) {
    for (int j = 1; j < i; j++)
      if (col[j] == 0) {
        swap_col(i, j);
        output.push_back(make_pair(2, make_pair(i, j)));
        break;
      }
    for (int j = 1; j < i; j++) {
      if (row[j] >= 1) {
        swap_row(j, i);
        output.push_back(make_pair(1, make_pair(i, j)));
        break;
      }
    }
    memset(row, 0, sizeof row);
    memset(col, 0, sizeof col);
    for (int j = 1; j < i; j++)
      for (int k = 1; k < i; k++) row[j] += grid[j][k];
    for (int j = 1; j < i; j++)
      for (int k = 1; k < i; k++) col[k] += grid[j][k];
  }
  cout << output.size() << endl;
  for (int i = 0; i < output.size(); i++) {
    cout << output[i].first << " " << output[i].second.first << " "
         << output[i].second.second << endl;
  }
  return 0;
}
