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 PYTHON):

Solution:
import io;
import sys;
import math;
import bisect as bs;
import heapq;
# IO Method #

def read_int() :
	return map(int, raw_input().split());

def read_string() :
	return raw_input().split();

def read_float() :
	return map(float, raw_input().split());

# End #

# Data Structures #

class LinkedList :

	def __init__(self) :
		self.head = Node(); # Always null
		self.tail = Node(); # Always null
		self.now = Node(); # Init it first #
		# Create link #
		self.head.next = self.now;
		self.tail.prev = self.now;
		self.now.prev = self.head;
		self.now.next = self.tail;

		# Create attrib #
		self.__first = True;
		self.size = 0;

		pass

	def next(self) :
		return self.now.next;

	def prev(self) :
		return self.now.prev;

	def __setNow(self, data) :
		self.now.data = data;
		self.__first = False;
		pass

	def addFirst(self, data) :
		if self.__first :
			self.__setNow(data); 
		else :
			newNode = Node(data, self.head, self.head.next);
			self.head.next = newNode;
			newNode.next.prev = newNode;
			self.size += 1;
		pass

	def addLast(self, data) :
		if self.__first :
			self.__setNow(data); 
		else :
			newNode = Node(data, self.tail.prev, self.tail);
			self.tail.prev = newNode;
			newNode.prev.next = newNode;
			self.size += 1;
		pass

	def addNext(self, data) :
		if self.__first :
			self.__setNow(data); 
		else :
			newNode = Node(data, self.now, self.now.next);
			self.now.next = newNode;
			newNode.next.prev = newNode;
			self.size += 1;
		pass

	def addPrev(self, data) :
		if self.__first :
			self.__setNow(data); 
		else :
			newNode = Node(data, self.now.prev, self.now);
			self.now.prev = newNode;
			newNode.prev.next = newNode;
			self.size += 1;
		pass

	def toList(self) :
		currNode = self.head.next;
		res = [];
		while (currNode != self.tail) :
			res.append(currNode.data);
			currNode = currNode.next;
			pass
		return res;

	def __str__(self) :
		return str(self.toList());

class Node :

	def __init__(self, data = None, prev=None, next=None) :
		self.prev = prev;
		self.next = next;
		self.data = data;
		pass

	def __str__(self) :
		return str(self.data)

# Main Entry #

if __name__ == '__main__': 

	sides = input();
	
	one_row = [0 for _ in xrange(sides)];
	one_col = [0 for _ in xrange(sides)];
	row = [0 for _ in xrange(sides-1)];
	col = [0 for _ in xrange(sides-1)];
	ans = [];

	for ii in xrange(sides-1) :
		a, b = read_int();
		a -= 1;
		b -= 1;
		
		one_row[a] += 1;
		one_col[b] += 1;
		row[ii] = a;
		col[ii] = b;
		pass

	def debug() :
		print "-----"

		matrix = [[0 for _ in xrange(sides)] for _ in xrange(sides)];
		for ii in xrange(sides-1) :
			matrix[row[ii]][col[ii]] = 1;

		for ii in xrange(sides) :
			for jj in xrange(sides) :
				print matrix[ii][jj],;
				pass
			print "";
			pass

		print "-----"

		pass

	def swaprc(rc, a, b) :
		if rc == 1 :
			for ii in xrange(sides-1) :
				if row[ii] == a :
					row[ii] = b;
				elif row[ii] == b :
					row[ii] = a; 

			one_row[a], one_row[b] = one_row[b], one_row[a];

		else :
			for ii in xrange(sides-1) :
				if col[ii] == a :
					col[ii] = b;
				elif col[ii] == b :
					col[ii] = a; 

			one_col[a], one_col[b] = one_col[b], one_col[a];

		ans.append([rc, a, b]);

		pass

	# search empty column #
	lidx = sides-1;
	for ii in xrange(sides) :
		if lidx <= ii :
			break;

		if one_col[ii] == 0 :
			swaprc(2, ii, lidx);
			lidx -= 1;
		pass;

	# greedyly get farthest col in row r #
	far = [-1 for _ in xrange(sides)];
	for ii in xrange(sides-1) :
		far[row[ii]] = max(far[row[ii]], col[ii]);
		pass


	# selection sort for row #
	for ii in xrange(sides-1, -1, -1) :
		maxitem = -1;
		maxidx = -1;
		for jj in xrange(0, ii+1) :
			if far[jj] > maxitem :
				maxitem = far[jj];
				maxidx = jj;
				pass
			pass
		if maxidx == -1 :
			break;
		if maxidx != ii :
			swaprc(1, maxidx, ii); 
			far[maxidx], far[ii] = far[ii], far[maxidx];
	
	#debug();
	print len(ans)
	for ii in xrange(len(ans)) :
		print ans[ii][0], ans[ii][1]+1, ans[ii][2]+1;

	pass


# End #