#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int MAX = 2e3 + 5;
const long long MAX2 = 11;
const long long MOD = 1000000007;
const long long INF = 1e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;
int n, a, b, id, y[MAX];
bool x[MAX][MAX], st, z[MAX];
vector<pair<int, pair<int, int> > > ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 2; i <= n; ++i) {
    cin >> a >> b;
    x[a][b] = 1;
  }
  id = 1;
  for (long long j = n; j >= 1; --j) {
    st = 0;
    for (long long i = 1; i <= n; ++i) st |= x[i][j];
    if (st) {
      while (id < j) {
        st = 0;
        for (long long i = 1; i <= n; ++i) st |= x[i][id];
        if (!st) break;
        ++id;
      }
      if (id < j) {
        for (long long i = 1; i <= n; ++i) x[i][id] = x[i][j];
        for (long long i = 1; i <= n; ++i) x[i][j] = 0;
        ans.push_back({2, {id, j}});
        ++id;
      } else
        break;
    }
  }
  id = n;
  for (long long i = 1; i <= n; ++i) {
    st = 0;
    for (long long j = 1; j <= n; ++j) st |= x[i][j];
    if (st) {
      while (id > i) {
        st = 0;
        for (long long j = 1; j <= n; ++j) st |= x[id][j];
        if (!st) break;
        --id;
      }
      if (id > i) {
        for (long long j = 1; j <= n; ++j) x[id][j] = x[i][j];
        for (long long j = 1; j <= n; ++j) x[i][j] = 0;
        ans.push_back({1, {id, i}});
        --id;
      } else
        break;
    }
  }
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= n; ++j)
      if (x[i][j]) y[i] = j;
  for (long long i = 1; i <= n; ++i) {
    if (y[i] >= i) {
      for (long long j = i + 1; j <= n; ++j)
        if (y[j] < i) {
          swap(y[i], y[j]), ans.push_back({1, {i, j}});
          break;
        }
    }
  }
  cout << ans.size() << "\n";
  for (auto i : ans)
    cout << i.first << " " << i.second.first << ' ' << i.second.second << "\n";
  return 0;
}
