Problem: You are given a square matrix consisting of n rows and n columns. We assume that the rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to n from left to right. Some cells (n - 1 cells in total) of the the matrix are filled with ones, the remaining cells are filled with zeros. We can apply the following operations to the matrix:

  1. Swap i-th and j-th rows of the matrix; 
  2. Swap i-th and j-th columns of the matrix. 



You are asked to transform the matrix into a special form using these operations. In that special form all the ones must be in the cells that lie below the main diagonal. Cell of the matrix, which is located on the intersection of the i-th row and of the j-th column, lies below the main diagonal if i > j.

Input

The first line contains an integer n (2 ≤ n ≤ 1000) — the number of rows and columns. Then follow n - 1 lines that contain one's positions, one per line. Each position is described by two integers xk, yk (1 ≤ xk, yk ≤ n), separated by a space. A pair (xk, yk) means that the cell, which is located on the intersection of the xk-th row and of the yk-th column, contains one.

It is guaranteed that all positions are distinct.

Output

Print the description of your actions. These actions should transform the matrix to the described special form.

In the first line you should print a non-negative integer m (m ≤ 105) — the number of actions. In each of the next m lines print three space-separated integers t, i, j (1 ≤ t ≤ 2, 1 ≤ i, j ≤ n, i ≠ j), where t = 1 if you want to swap rows, t = 2 if you want to swap columns, and i and j denote the numbers of rows or columns respectively.

Please note, that you do not need to minimize the number of operations, but their number should not exceed 105. If there are several solutions, you may print any of them.

Examples

Input

2
1 2


Output

2
2 1 2
1 1 2


Input

3
3 1
1 3


Output

3
2 2 3
1 1 3
1 1 2


Input

3
2 1
3 2


Output

0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 100005;
const double PI = 4 * atan(1);
const long long MAX = 9223372036854775807;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
bool issquare(long long w) { return trunc(sqrt(w)) * trunc(sqrt(w)) == w; }
bool isprime(long long u) {
  for (long long i = 2; i <= (int)sqrt(u); i++) {
    if (u % i == 0) return 0;
  }
  return 1;
}
long long mod(long long to_mod) {
  to_mod %= MOD;
  while (to_mod < 0) to_mod += MOD;
  return to_mod % MOD;
}
long long moduloMultiplication(long long a, long long b, long long mod) {
  long long res = 0;
  a %= mod;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long n, m, x, y, res, t, k, ans = 0, b, q, z, a;
long long row[1005];
vector<long long> row1[1005];
long long col[1005];
long long revcol[1005];
vector<long long> v;
vector<pair<long long, pair<long long, long long> > > vvv;
vector<pair<long long, long long> > vv;
int main() {
  ios::sync_with_stdio(0);
  memset(row, 0, sizeof(row));
  cin >> n;
  col[n - 1] = n - 1;
  revcol[n - 1] = n - 1;
  for (int i = 0; i < n - 1; i++) {
    col[i] = i;
    revcol[i] = i;
    cin >> x >> y;
    x--;
    y--;
    row[x]++;
    row1[x].push_back(y);
    vv.push_back(make_pair(x, y));
  }
  for (int i = 0; i < n; i++) {
    v.push_back(row[i]);
    sort(row1[i].begin(), row1[i].end());
  }
  sort(v.begin(), v.end());
  a = 0;
  for (int i = 0; i < n; i++) {
    if (row[i] != v[i]) {
      z = 0;
      for (int j = i + 1; j < n; j++) {
        if (row[j] == v[i]) {
          z = j;
          break;
        }
      }
      vvv.push_back(make_pair(1, make_pair(i + 1, z + 1)));
      swap(row[i], row[z]);
      swap(row1[i], row1[z]);
    }
    if (row[i] == 0) continue;
    for (auto t : row1[i]) {
      if (col[t] < a) continue;
      if (col[t] != a)
        vvv.push_back(make_pair(2, make_pair(col[t] + 1, a + 1)));
      z = col[t];
      col[t] = a;
      col[revcol[a]] = z;
      b = revcol[a];
      revcol[a] = t;
      revcol[z] = b;
      a++;
    }
  }
  cout << vvv.size() << endl;
  for (auto t : vvv) {
    cout << t.first << " " << t.second.first << " " << t.second.second << endl;
  }
  return 0;
}