#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
long long int bst(long long int a[], long long int item, long long int index,
                  long long int n) {
  long long int b = index, e = n, mid;
  mid = (b + e) / 2;
  while (a[mid] != item && b <= e) {
    if (a[mid] < item)
      b = mid + 1;
    else
      e = mid - 1;
    mid = (b + e) / 2;
  }
  return mid;
}
long long int max3(long long int x, long long int y, long long int z) {
  return max(max(x, y), z);
}
long long int min3(long long int x, long long int y, long long int z) {
  return min(min(x, y), z);
}
string cir_shift(string s) {
  string s1;
  long long int len;
  len = s.size();
  s1 = s.substr(1, len - 1);
  s1.push_back(s[0]);
  return s1;
}
template <typename Type>
void swap1(Type &a, Type &b) {
  Type temp;
  temp = a;
  a = b;
  b = temp;
}
long long int a[1001][1001];
void scolumn(long long int x, long long int y, long long int n) {
  long long int i;
  for (i = 1; i <= n; i++) {
    swap1(a[i][x], a[i][y]);
  }
}
void srow(long long int x, long long int y, long long int n) {
  long long int i;
  for (i = 1; i <= n; i++) {
    swap1(a[x][i], a[y][i]);
  }
}
void print(long long int n) {
  long long int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}
bool comp(pair<long long int, long long int> x,
          pair<long long int, long long int> y) {
  return x.second < y.second;
}
bool comp1(pair<long long int, long long int> x,
           pair<long long int, long long int> y) {
  return x.first < y.first;
}
long long int c[1001], d[1001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  vector<pair<long long int, pair<long long int, long long int> > > v;
  long long int n, x, y, cnt = 0, i, j, k, ind, num;
  cin >> n;
  vector<pair<long long int, long long int> > row, col;
  for (i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    a[x][y] = 1;
  }
  for (i = 1; i <= n; i++) {
    c[i] = d[i] = i;
    for (k = n; k >= 1; k--) {
      if (a[i][k] == 1) break;
    }
    row.push_back({i, k});
  }
  sort(row.begin(), row.end(), comp);
  for (i = 1; i <= n; i++) {
    if (c[i] != row[i - 1].first) {
      num = c[i];
      ind = d[row[i - 1].first];
      v.push_back({1, {i, ind}});
      srow(i, ind, n);
      c[i] = row[i - 1].first;
      c[ind] = num;
      d[num] = ind;
      d[row[i - 1].first] = i;
    }
  }
  for (i = 1; i <= n; i++) {
    for (k = 1; k <= n; k++) {
      if (a[k][i] == 1) break;
    }
    col.push_back(make_pair(k, i));
  }
  sort(col.begin(), col.end(), comp1);
  for (i = 1; i <= n; i++) {
    c[i] = d[i] = i;
  }
  for (i = 1; i <= n; i++) {
    if (c[i] != col[i - 1].second) {
      num = c[i];
      ind = d[col[i - 1].second];
      v.push_back({2, {i, ind}});
      scolumn(i, ind, n);
      c[i] = col[i - 1].second;
      c[ind] = num;
      d[num] = ind;
      d[col[i - 1].second] = i;
    }
  }
  x = v.size();
  cout << x << endl;
  for (i = 0; i <= x - 1; i++) {
    cout << v[i].first << " " << v[i].second.first << " " << v[i].second.second
         << endl;
  }
}
