#include <bits/stdc++.h>
using namespace std;
struct swapop {
  int t, i, j;
  swapop(int t, int i, int j) {
    this->t = t;
    this->i = i;
    this->j = j;
  }
};
int id[1005];
vector<int> row[1005];
vector<swapop> ans;
int n;
void make_swap(int t, int i, int j) {
  if (i == j) return;
  ans.push_back(swapop(t, i + 1, j + 1));
  if (t == 1) {
    swap(id[i], id[j]);
  }
}
int main() {
  scanf("%d", &n);
  id[n - 1] = n - 1;
  for (int i = 0; i < n - 1; ++i) {
    id[i] = i;
    int x, y;
    scanf("%d %d", &x, &y);
    --x, --y;
    row[x].push_back(y);
  }
  int allzerorow;
  for (int i = 0; i < n; ++i) {
    sort(row[i].begin(), row[i].end());
    if (row[i].size() == 0) allzerorow = i;
  }
  make_swap(1, 0, allzerorow);
  int c = 0;
  for (int r = 1; r < n; ++r) {
    int onesneeded = r - c;
    int remzero = -1;
    bool good = false;
    for (int i = r; i < n; ++i) {
      vector<int> &currow = row[id[i]];
      int sz = currow.size();
      int ind = lower_bound(currow.begin(), currow.end(), c) - currow.begin();
      if (ind == currow.size()) remzero = i;
      if (sz - ind == onesneeded) {
        good = true;
        make_swap(1, r, i);
        for (int j = 0; j < onesneeded; ++j, ++c) {
          make_swap(2, c, currow[ind + j]);
          int col1 = c, col2 = currow[ind + j];
          for (int k = r + 1; k < n; ++k) {
            int pos1 = lower_bound(row[id[k]].begin(), row[id[k]].end(), col2) -
                       row[id[k]].begin();
            int pos2 = lower_bound(row[id[k]].begin(), row[id[k]].end(), col1) -
                       row[id[k]].begin();
            if (pos1 != row[id[k]].size()) {
              if (row[id[k]][pos1] == col2) row[id[k]][pos1] = col1;
            }
            if (pos2 != row[id[k]].size()) {
              if (row[id[k]][pos2] == col1) row[id[k]][pos2] = col2;
            }
            sort(row[id[k]].begin(), row[id[k]].end());
          }
        }
        break;
      }
    }
    if (!good) make_swap(1, r, remzero);
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d %d %d\n", ans[i].t, ans[i].i, ans[i].j);
  }
  return 0;
}
