Problem: Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way roads. Because of the recent financial crisis, the Berland Government is strongly pressed for money, so to build a new road it has to close some of the existing ones. Every day it is possible to close one existing road and immediately build a new one. Your task is to determine how many days would be needed to rebuild roads so that from each city it became possible to reach all the others, and to draw a plan of closure of old roads and building of new ones.

Input

The first line contains integer n (2 ≤ n ≤ 1000) — amount of cities in Berland and neighboring countries. Next n - 1 lines contain the description of roads. Each road is described by two space-separated integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — pair of cities, which the road connects. It can't be more than one road between a pair of cities. No road connects the city with itself.

Output

Output the answer, number t — what is the least amount of days needed to rebuild roads so that from each city it became possible to reach all the others. Then output t lines — the plan of closure of old roads and building of new ones. Each line should describe one day in the format i j u v — it means that road between cities i and j became closed and a new road between cities u and v is built. Cities are numbered from 1. If the answer is not unique, output any.

Examples

Input

2
1 2


Output

0


Input

7
1 2
2 3
3 1
4 5
5 6
6 7


Output

1
3 1 3 7

Solution (in PYTHON3):

Solution:
class DSU:
	nodes = []
	duplicates = []

	def __init__(self,n):
		self.nodes = [[0,0] for i in range(n)]

	def find(self,x):
		return self.nodes[x]

	def union(self,x,y):
		xRoot,yRoot = self.find(x),self.find(y)
		if xRoot[0] == yRoot[0]:
			self.duplicates.append([x,y])
			return
		connections = xRoot[1] + yRoot[1]
		xRoot_pointer__original = xRoot[0]
		yRoot_pointer__original = yRoot[0]
		if xRoot[1] > yRoot[1]:
			for node in self.nodes:
				if node[0] == yRoot_pointer__original or node[0] == xRoot_pointer__original:
					node[0] = xRoot_pointer__original
					node[1] = connections
		else:
			for node in self.nodes:
				if node[0] == xRoot_pointer__original or node[0] == yRoot_pointer__original:
					node[0] = yRoot_pointer__original
					node[1] = connections

	def insert(self,x,y):
		if self.nodes[x][0] == 0 and self.nodes[y][0] == 0:
			self.nodes[x] = [x,2]
			self.nodes[y] = [x,2]
		elif self.nodes[x][0] != 0 and self.nodes[y][0] != 0:
			self.union(x,y)
		elif self.nodes[x][0] != 0:
			self.nodes[y] = [y,1]
			self.union(x,y)
		elif self.nodes[y][0] != 0:
			self.nodes[x] = [x,1]
			self.union(x,y)

n = int(input())
dsu = DSU(n+1)
for i in range(n-1):
	a = list(map(int,input().split()))
	x,y = a[0],a[1]
	dsu.insert(x,y)

new_roads = []
connected = -1

for i in range(1,len(dsu.nodes)):
	if dsu.nodes[i] != [0,0]:
		connected = i
		break


for i in range(len(dsu.duplicates)):
	for i in range(1,len(dsu.nodes)):
		if dsu.nodes[i][0] != dsu.nodes[connected][0] and dsu.nodes[i] != [0,0]:
			dsu.union(connected,i)
			new_roads.append([connected,i])
			break

for i in range(1,len(dsu.nodes)):
	if dsu.nodes[i] == [0,0]:
		#dsu.union(connected,i)
		new_roads.append([connected,i])

print(len(new_roads))

for i in range(len(new_roads)):
	print(dsu.duplicates[i][0],dsu.duplicates[i][1],new_roads[i][0],new_roads[i][1])



'''
21
7 15
13 1
14 3
4 10
2 3
16 18
17 20
16 20
8 4
3 12
2 17
13 11
16 1
13 2
13 5
8 9
6 14
3 17
16 9
13 8


10
5 9
8 5
7 6
7 9
3 9
2 1
7 2
3 6
7 1

'''