The Berland capital (as you very well know) contains n junctions, some pairs of which are connected by two-way roads. Unfortunately, the number of traffic jams in the capital has increased dramatically, that's why it was decided to build several new roads. Every road should connect two junctions. 

The city administration noticed that in the cities of all the developed countries between any two roads one can drive along at least two paths so that the paths don't share any roads (but they may share the same junction). The administration decided to add the minimal number of roads so that this rules was fulfilled in the Berland capital as well. In the city road network should exist no more than one road between every pair of junctions before or after the reform.

Input

The first input line contains a pair of integers n, m (2 ≤ n ≤ 900, 1 ≤ m ≤ 100000), where n is the number of junctions and m is the number of roads. Each of the following m lines contains a description of a road that is given by the numbers of the connected junctions ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi). The junctions are numbered from 1 to n. It is possible to reach any junction of the city from any other one moving along roads.

Output

On the first line print t — the number of added roads. Then on t lines print the descriptions of the added roads in the format of the input data. You can use any order of printing the roads themselves as well as the junctions linked by every road. If there are several solutions to that problem, print any of them.

If the capital doesn't need the reform, print the single number 0.

If there's no solution, print the single number -1.

Examples

Input

4 3
1 2
2 3
3 4


Output

1
1 4


Input

4 4
1 2
2 3
2 4
3 4


Output

1
1 3

Difficulty: HARD
Tags: Graph algorithms

Starter code:

Solutions:
import sys
import threading

def main():
	p = input().split()
	n = int(p[0])
	m = int(p[1])
	if n == 1:
		print(0)
		return
	if n == 2:
		print(-1)
		return
	g = graph(n, m)
	g.buildBridgeTree()
	e = graph(len(g.bridges) + 1, len(g.bridges))
	e.conexions = []
	e.pi = []
	e.discovery = []
	e.seen = []
	for i in range(len(g.bridges) + 1):
		e.conexions.append([])
		e.pi.append(-1)
		e.discovery.append(sys.float_info.max)
		e.seen.append(False)
	for i in range(len(g.bridges)):
		e.conexions[g.cc[g.bridges[i][0]]].append((g.cc[g.bridges[i][1]], True))
		e.conexions[g.cc[g.bridges[i][1]]].append((g.cc[g.bridges[i][0]], True))
	e.bridges = g.bridges
	e.bridge = g.bridge
	e.cc = g.cc
	e.CC = e.CC
	e.CC
	e.treeDiameter()
	print(len(e.newEdges))
	for i in range(len(e.newEdges)):
		u = e.newEdges[i][0] + 1
		v = e.newEdges[i][1] + 1
		print(u, end=' ')
		print(v)

class graph:
	n = int()
	edges = int()
	time = int()
	conexions = []
	bridges = []
	bridge = []
	discovery = []
	seen = []
	cc = []
	low = []
	pi = []
	CC = []
	newEdges = []

	def __init__(self, n, m):
		self.n = n
		self.edges = m
		for i in range(self.n):
			self.conexions.append([])
			self.discovery.append(sys.float_info.max)
			self.low.append(sys.float_info.max)
			self.seen.append(False)
			self.cc.append(-1)
			self.CC.append([])
			self.bridge.append([])

	def buildGraph(self):
		for i in range(self.edges):
			p2 = input().split()
			self.conexions[int(p2[0]) - 1].append((int(p2[1]) - 1, False))
			self.conexions[int(p2[1]) - 1].append((int(p2[0]) - 1, False))

	def searchBridges(self):
		self.time = 0
		for i in range(self.n):
			self.pi.append(-1)
			for j in range(self.n):
				self.bridge[i].append(False)
		self.searchBridges_(0, -1)

	def searchBridges_(self, c, index):
		self.seen[c] = True
		self.time += 1
		self.discovery[c] = self.low[c] = self.time
		for i in range(len(self.conexions[c])):
			pos = self.conexions[c][i][0]
			if not self.seen[pos]:
				self.pi[pos] = c
				self.searchBridges_(pos, i)
				self.low[c] = min([self.low[c], self.low[pos]])
			elif self.pi[c] != pos:
				self.low[c] = min([self.low[c], self.discovery[pos]])
		if self.pi[c] != -1 and self.low[c] == self.discovery[c]:
			self.bridges.append((c, self.pi[c]))
			self.bridge[self.pi[c]][c] = self.bridge[c][self.pi[c]] = True
			for i in range(len(self.conexions[c])):
				if self.conexions[c][i][0] == self.pi[c]:
					self.conexions[c][i] = (self.pi[c], True)
					self.conexions[self.pi[c]][index] = (c, True)

	def findCC(self):
		j = 0
		for i in range(self.n):
			self.pi[i] = -1
			self.seen[i] = False
		for i in range(self.n):
			if self.seen[i] == False:
				self.cc[i] = j
				self.CC[j].append(i)
				self.findCC_(i, j)
				j += 1

	def findCC_(self, c, j):
		self.seen[c] = True
		for i in range(len(self.conexions[c])):
			pos = self.conexions[c][i][0]
			if self.seen[pos] == False and self.conexions[c][i][1] == False:
				self.cc[pos] = j
				self.CC[j].append(pos)
				self.pi[pos] = c
				self.findCC_(pos, j)

	def treeDiameter(self):
		while self.n > 1:
			for i in range(self.n):
				self.seen[i] = False
				self.pi[i] = -1
			self.discovery[0] = 0
			self.treeDiameter_(0)
			max = -1
			maxIndex = 0
			for i in range(self.n):
				if self.discovery[i] > max:
					max = self.discovery[i]
					maxIndex = i
			for i in range(self.n):
				self.seen[i] = False
				self.pi[i] = -1
			self.discovery[maxIndex] = 0
			self.treeDiameter_(maxIndex)
			max = -1
			maxIndex2 = -1
			for i in range(self.n):
				if self.discovery[i] > max:
					max = self.discovery[i]
					maxIndex2 = i
			self.ReBuildTree(maxIndex, maxIndex2)

	def treeDiameter_(self, c):
		self.seen[c] = True
		for i in range(len(self.conexions[c])):
			pos = self.conexions[c][i][0]
			if self.seen[pos] == False:
				self.pi[pos] = c
				self.discovery[pos] = self.discovery[c] + 1
				self.treeDiameter_(pos)

	def buildBridgeTree(self):
		self.buildGraph()
		self.searchBridges()
		self.findCC()

	def ReBuildTree(self, u, v):
		find = 0
		for i in range(len(self.CC[u])):
			for j in range(len(self.CC[v])):
				if not self.bridge[self.CC[u][i]][self.CC[v][j]]:
					self.newEdges.append((self.CC[u][i], self.CC[v][j]))
					find = 1
					break
			if find == 1:
				break
		newIndex = []
		temp = v
		self.conexions[u] = None
		self.conexions[v] = None
		while self.pi[temp] != u:
			self.conexions[self.pi[temp]] = None
			temp = self.pi[temp]
		r = 1
		for i in range(self.n):
			if self.conexions[i] != None:
				newIndex.append(r)
				r += 1
			else:
				newIndex.append(0)
		self.n = r
		if self.n == 1:
			return
		newCC = []
		self.conexions = []
		for i in range(self.n):
			self.conexions.append([])
			newCC.append([])
		for i in range(len(self.bridges)):
			len0 = len(self.CC[self.cc[self.bridges[i][0]]])
			if len0 != 0:
				for j in range(len0):
					newCC[newIndex[self.cc[self.bridges[i][0]]]].append(self.CC[self.cc[self.bridges[i][0]]][j])
				self.CC[self.cc[self.bridges[i][0]]] = []
			len1 = len(self.CC[self.cc[self.bridges[i][1]]])
			if len1 != 0:
				for j in range(len1):
					newCC[newIndex[self.cc[self.bridges[i][1]]]].append(self.CC[self.cc[self.bridges[i][1]]][j])
				self.CC[self.cc[self.bridges[i][1]]] = []
			self.conexions[newIndex[self.cc[self.bridges[i][0]]]].append((newIndex[self.cc[self.bridges[i][1]]], True))
			self.conexions[newIndex[self.cc[self.bridges[i][1]]]].append((newIndex[self.cc[self.bridges[i][0]]], True))
		self.CC = newCC
		for i in range(len(self.cc)):
			self.cc[i] = newIndex[self.cc[i]]
main()


def dfs1(v):
	mark[v] = 1
	st.append(v)
	dp[v] = d[v]
	for u in adj[v]:
		if not mark[u]:
			d[u] = d[v] + 1
			dfs1(u)
			dp[v] = min(dp[u], dp[v])
		elif d[u] < d[v] - 1:
			dp[v] = min(dp[v], d[u])
	if dp[v] == d[v]:
		ver[cnt[0]] = v
		prv = -1
		while prv != v:
			prv = st.pop()
			if d[ver[cnt[0]]] < d[prv]:
				ver[cnt[0]] = prv
			col[prv] = cnt[0]
			for u in adj[prv]:
				if col[u] != -1 and col[u] != cnt[0]:
					child[cnt[0]].append(col[u])
		cnt[0] += 1
cnt = [0]
N = 100000
adj = [[] for i in range(N)]
child = [[] for i in range(N)]
ord = []
mark = [False] * N
dp = [-1] * N
d = [-1] * N
st = []
col = [-1] * N
ver = [-1] * N
(n, m) = map(int, input().split())
if n == 2 and m == 1:
	print('-1')
	exit(0)
for i in range(m):
	(u, v) = map(int, input().split())
	adj[v - 1].append(u - 1)
	adj[u - 1].append(v - 1)
dfs1(0)
ver[cnt[0] - 1] = 0
if cnt[0] == 1:
	print('0')
	exit(0)
for i in range(cnt[0]):
	if len(child[i]) == 0:
		ord.append(i)
if len(child[cnt[0] - 1]) == 1:
	ord.append(cnt[0] - 1)
ans = int((len(ord) + 1) / 2)
print(ans)
ans1 = 0
ans2 = 0
for i in range(ans):
	ans1 = ver[ord[i]] + 1
	ans2 = ver[ord[min(len(ord), int(i + len(ord) / 2))]] + 1
	print(ans1, ans2)