A country has n cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities. Roads can be traversed either way. He wants those roads to be constructed in such a way that it is possible to go from each city to any other city by traversing at most two roads. You are also given m pairs of cities — roads cannot be constructed between these pairs of cities.

Your task is to construct the minimum number of roads that still satisfy the above conditions. The constraints will guarantee that this is always possible.


-----Input-----

The first line consists of two integers n and m $(1 \leq n \leq 10^{3}, 0 \leq m < \frac{n}{2})$.

Then m lines follow, each consisting of two integers a_{i} and b_{i} (1 ≤ a_{i}, b_{i} ≤ n, a_{i} ≠ b_{i}), which means that it is not possible to construct a road connecting cities a_{i} and b_{i}. Consider the cities are numbered from 1 to n.

It is guaranteed that every pair of cities will appear at most once in the input.


-----Output-----

You should print an integer s: the minimum number of roads that should be constructed, in the first line. Then s lines should follow, each consisting of two integers a_{i} and b_{i} (1 ≤ a_{i}, b_{i} ≤ n, a_{i} ≠ b_{i}), which means that a road should be constructed between cities a_{i} and b_{i}.

If there are several solutions, you may print any of them.


-----Examples-----
Input
4 1
1 3

Output
3
1 2
4 2
2 3



-----Note-----

This is one possible solution of the example:  [Image] 

These are examples of wrong solutions: [Image]  The above solution is wrong because it doesn't use the minimum number of edges (4 vs 3). In addition, it also tries to construct a road between cities 1 and 3, while the input specifies that it is not allowed to construct a road between the pair. [Image]  The above solution is wrong because you need to traverse at least 3 roads to go from city 1 to city 3, whereas in your country it must be possible to go from any city to another by traversing at most 2 roads. [Image]  Finally, the above solution is wrong because it must be possible to go from any city to another, whereas it is not possible in this country to go from city 1 to 3, 2 to 3, and 4 to 3.

Source: codeforces | Difficulty: EASY
Tags: Graph algorithms

Constructive algorithms


Solutions:
ROADS = 0

def find_center_citie(condition, num_of_citie):
	res = []
	for i in range(number_of_city):
		count = [j for j in condition if j[0] == i + 1 or j[1] == i + 1]
		res.append(len(count))
	center = res.index(min(res)) + 1
	return center

def acess(i, j, cities):
	citie_1 = i + 1
	citie_2 = j + 1
	if cities[i].count(citie_2) == 1:
		return True
	for c in cities[i]:
		for c2 in cities[c - 1]:
			if c2 == citie_2:
				return True
	return False

def print_road(cities):
	for c2 in cities:
		print(c2[0], c2[1])

def finnesh(cities, num_of_citie):
	for i in range(number_of_city):
		for j in range(i + 1, number_of_city):
			if acess(i, j, cities) == False:
				return False
	return True
condition = []
path_lst = []
line = [int(i) for i in input().split()]
number_of_city = line[0]
number_of_codition = line[1]
for i in range(number_of_codition):
	citie = [int(i) for i in input().split()]
	condition.append([citie[0], citie[1]])
cities = [[] for _ in range(number_of_city)]
center = find_center_citie(condition, number_of_city)
for i in range(number_of_city):
	if i != center - 1 and condition.count([center, i + 1]) == 0 and (condition.count([i + 1, center]) == 0):
		cities[center - 1].append(i + 1)
		path_lst.append([center, i + 1])
		cities[i].append(center)
		ROADS += 1
if len(cities[center - 1]) != number_of_city - 1:
	for i in range(number_of_city):
		for j in range(i + 1, number_of_city):
			if acess(i, j, cities) == False:
				if condition.count([j + 1, i + 1]) == 0 and condition.count([i + 1, j + 1]) == 0:
					cities[i].append(j + 1)
					cities[j].append(i + 1)
					path_lst.append([i + 1, j + 1])
				else:
					for k in cities[i]:
						if cities[k - 1].count(j + 1) == 0 and condition.count([j + 1, k]) == 0 and (condition.count([k, j + 1]) == 0):
							cities[k - 1].append(j + 1)
							cities[j].append(k)
							path_lst.append([j + 1, k])
							break
				ROADS += 1
print(ROADS)
print_road(path_lst)


(n, m) = map(int, input().split(' '))
pk = [i for i in range(1, n + 1)]
dele = [False for i in range(n)]
for i in range(m):
	(u, v) = map(int, input().split(' '))
	if dele[u - 1] == False:
		pk.remove(u)
		dele[u - 1] = True
	if dele[v - 1] == False:
		pk.remove(v)
		dele[v - 1] = True
cen = pk.pop(0)
print(n - 1)
for i in range(1, n + 1):
	if i == cen:
		continue
	else:
		print(cen, end=' ')
		print(i)


(n, m) = list(map(int, input().split()))
t = set()
for i in range(m):
	(x, y) = list(map(int, input().split()))
	t.add(x)
	t.add(y)
for i in range(1, n + 1):
	m = i if i not in t else m
print(n - 1)
for i in range(1, n + 1):
	if i != m:
		print(i, m)


(n, k) = map(int, input().split())
nocenter = set()
for i in range(k):
	(a, b) = map(int, input().split())
	nocenter.add(a)
	nocenter.add(b)
city = 1
for i in range(1, n + 1):
	if i not in nocenter:
		city = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != city:
		print(i, city)


(n, m) = map(int, input().split())
a = list(range(0, n + 1))
for i in range(m):
	(x, y) = map(int, input().split())
	a[x] = a[y] = -1
x = -1
for i in range(1, n + 1):
	x = i
	if a[i] > 0:
		break
print(n - 1)
for i in range(1, n + 1):
	if i != x:
		print(x, i)


(n, m) = map(int, input().strip().split(' '))
s = [True for _ in range(n + 1)]
while m:
	m -= 1
	(x, y) = map(int, input().strip().split(' '))
	s[x] = False
	s[y] = False
for i in range(1, n + 1):
	if s[i]:
		centr = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != centr:
		print(centr, i)


(n, m) = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(m)]
r = [[True for j in range(n + 1)] for i in range(n + 1)]
for v in c:
	r[v[0]][v[1]] = False
	r[v[1]][v[0]] = False
node = -1
for i in range(1, n + 1):
	cont = True
	for j in range(1, n + 1):
		cont &= r[i][j]
		if not cont:
			break
	if cont:
		node = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != node:
		print(node, i)


(n, m) = list(map(int, input().split(' ')))
b = []
a = set()
for _ in range(m):
	(i, j) = list(map(int, input().split(' ')))
	a.add(i)
	a.add(j)
a = list(a)
i = 0
for i in range(1, n + 1):
	if i not in a:
		break
print(n - 1)
for j in range(1, n + 1):
	if i != j:
		print(i, j)


(n, m) = list(map(int, input().split()))
a = set(range(1, n + 1))
for i in range(m):
	a = a - set(map(int, input().split()))
a = list(a)[0]
print(n - 1)
for i in range(1, n + 1):
	if i != a:
		print(a, i)


t = input().split()
n = int(t[0])
m = int(t[1])
s = set()
u = set((i for i in range(1, n + 1)))
for i in range(m):
	t = input().split()
	s.add(int(t[0]))
	s.add(int(t[1]))
uniq = (u - s).pop()
print(n - 1)
for i in range(1, n + 1):
	if i != uniq:
		print(i, uniq)


from sys import stdin

def main():
	(n, m) = map(int, input().split())
	nadj = [[] for _ in range(n)]
	for _ in range(m):
		(a, b) = map(int, stdin.readline().split())
		nadj[a - 1].append(b - 1)
		nadj[b - 1].append(a - 1)
	host = -1
	for i in range(n):
		if not nadj[i]:
			host = i
	print(n - 1)
	for i in range(n):
		if i != host:
			print(host + 1, i + 1)
main()


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input().split()))
(n, m) = I()
a = [0] * m
b = [0] * m
c = [0] * (n + 1)
for i in range(m):
	(a[i], b[i]) = I()
	c[a[i]] = 1
	c[b[i]] = 1
pt = 0
for i in range(1, n + 1):
	if c[i] == 0:
		pt = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != pt:
		print(pt, i)


(n, m) = [int(x) for x in input().split()]
arr = []
for i in range(n):
	arr.append(1)
for i in range(m):
	(p, q) = [int(x) for x in input().split()]
	arr[p - 1] = 0
	arr[q - 1] = 0
val = 0
for i in range(n):
	if arr[i] == 1:
		val = i + 1
		break
print(n - 1)
for i in range(n):
	if i + 1 != val:
		print(val, i + 1, sep=' ')


(cities, m) = map(int, input().split())
status = [0] * cities
for i in range(m):
	(a, b) = map(int, input().split())
	status[a - 1] = 1
	status[b - 1] = 2
central = 0
for i in range(cities):
	if status[i] == 0:
		central = i
		break
print(cities - 1)
for i in range(cities):
	if i != central:
		print(i + 1, central + 1)


(n, m) = map(int, input().split(' '))
arr = [0] * (n + 1)
for i in range(m):
	(a, b) = map(int, input().split(' '))
	arr[a] = 1
	arr[b] = 1
for i in range(1, n + 1):
	if arr[i] != 1:
		break
print(n - 1)
for j in range(1, n + 1):
	if j != i:
		print(i, j)


(n, m) = map(int, input().split())
pos_center = list(range(1, n + 1))
bad_roads = []
for i in range(m):
	bad_road = [int(i) for i in input().split()]
	for city in bad_road:
		if city in pos_center:
			pos_center.remove(city)
center = pos_center.pop(0)
others = list(range(1, n + 1))
others.remove(center)
print(n - 1)
for i in range(n - 1):
	print(center, others[i])


import math
import sys
(n, m) = map(int, input().split())
d = [[] for i in range(n)]
edges = {}
for i in range(m):
	(a, b) = map(int, input().split())
	d[a - 1].append(b - 1)
	d[b - 1].append(a - 1)
	edges
p = 0
for i in range(n):
	if len(d[i]) < len(d[p]):
		p = i
if len(d[p]) == 0:
	print(n - 1)
	for i in range(n):
		if i != p:
			print(p + 1, i + 1)
else:
	t = d[p][0]
	print(2 * n - 2)
	for i in range(n):
		if i != p and i != t:
			print(p + 1, i + 1)
	for i in range(n):
		if i != t and d[t][0] != i:
			print(t + 1, i + 1)


from sys import stdin, stdout

def build_proyects(n):
	proyects = {}
	roads_to_build = {}
	for i in range(1, n + 1):
		proyect = []
		for j in range(1, n + 1):
			if i < j:
				road = (i, j)
				proyect.append(road)
				if road in roads_to_build:
					roads_to_build[road].append(i)
				else:
					roads_to_build[road] = [i]
			elif j < i:
				road = (j, i)
				proyect.append(road)
				if road in roads_to_build:
					roads_to_build[road].append(i)
				else:
					roads_to_build[road] = [i]
		proyects[i] = proyect
	return (proyects, roads_to_build)

def test(n, m, forbbiden_roads):
	(proyects, roads_to_build) = build_proyects(n)
	for forbbiden_road in forbbiden_roads:
		forbidden_proyects = roads_to_build[forbbiden_road]
		for forbbiden_proyect in forbidden_proyects:
			if forbbiden_proyect in proyects:
				del proyects[forbbiden_proyect]
	(proyect_name, chosen_proyect) = proyects.popitem()
	return chosen_proyect
lst1 = [int(x) for x in stdin.readline().rstrip('\r\n').split()]
n = lst1[0]
m = lst1[1]
forbbiden_roads = []
for i in range(m):
	lst2 = [int(x) for x in stdin.readline().rstrip('\r\n').split()]
	if lst2[0] < lst2[1]:
		forbbiden_road = (lst2[0], lst2[1])
		forbbiden_roads.append(forbbiden_road)
	else:
		forbbiden_road = (lst2[1], lst2[0])
		forbbiden_roads.append(forbbiden_road)
proyect = test(n, m, forbbiden_roads)
road_len = len(proyect)
stdout.write('{0}\n'.format(road_len))
for road in proyect:
	stdout.write('{0} {1}\n'.format(road[0], road[1]))


import sys
(n, m) = input().split()
n = int(n)
m = int(m)
l = [0] * (n + 1)
r = 0
if n == 1:
	print(0)
	sys.exit()
for i in range(m):
	(e1, e2) = input().split()
	e1 = int(e1)
	e2 = int(e2)
	l[e1] = 1
	l[e2] = 1
for i in range(1, n + 1):
	if l[i] == 0:
		r = i
		break
print(n - 1)
for i in range(n):
	if i + 1 != r:
		print(r, i + 1)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
(n, m) = value()
s = set()
ans = []
for i in range(m):
	(a, b) = value()
	s.add(a)
	s.add(b)
for i in range(1, n + 1):
	if i not in s:
		break
print(n - 1)
for j in range(1, n + 1):
	if i != j:
		print(i, j)


(n, m) = list(map(int, input().split()))
print(n - 1)
t = []
for i in range(m):
	t += input().split()
t = set(t)
i = 1
while str(i) in t:
	i += 1
for j in range(1, i):
	print(i, j)
for j in range(i + 1, n + 1):
	print(i, j)


import sys
fin = sys.stdin
(n, m) = map(int, fin.readline().split())
noRoad = [tuple(map(int, fin.readline().split())) for i in range(m)]
canBeCenter = [True] * n
for (i, j) in noRoad:
	canBeCenter[i - 1] = canBeCenter[j - 1] = False
for i in range(n):
	if canBeCenter[i]:
		print(n - 1)
		for j in range(n):
			if i != j:
				print(i + 1, j + 1)
		break
else:
	print('Я неправильно решил задачу')


(n, m) = map(int, input().split())
con = list()
uni = list()
for i in range(0, m):
	(n1, n2) = map(int, input().split())
	con.append(n1)
	con.append(n2)
	if n1 not in uni:
		uni.append(n1)
	if n2 not in uni:
		uni.append(n2)
num = [x for x in range(1, n + 1)]
non_ava = list(set(num) - set(uni))
unique = non_ava[0]
print(len(num) - 1)
for i in num:
	if unique != i:
		print(unique, i)


(n, m) = map(int, input().split())
vis = [0 for _ in range(n + 1)]
for (x, y) in [map(int, input().split()) for _ in range(m)]:
	(vis[x], vis[y]) = (1, 1)
print(n - 1)
for i in range(1, n + 1):
	if vis[i] == 0:
		for j in range(1, 1 + n):
			if i != j:
				print(i, j)
		break


(n, m) = map(int, input().split())
s = set(range(1, n + 1))
for i in range(m):
	for j in map(int, input().split()):
		if j in s:
			s.remove(j)
c = s.pop()
print(n - 1)
for i in range(1, n + 1):
	if i != c:
		print(c, i)


import sys
inf = float('inf')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
myset = set()
for i in range(m):
	(x, y) = get_ints()
	myset.add(x)
	myset.add(y)
for node in range(1, n + 1):
	if node not in myset:
		break
print(n - 1)
for i in range(1, n + 1):
	if i == node:
		continue
	else:
		print(i, node)


(n, m) = list(map(int, input().split()))
p = dict()
h = []
dp = [0] * (n + 1)
for i in range(m):
	(a, b) = list(map(int, input().split()))
	h.append((a, b))
	p[a, b] = 1
	dp[a] = 1
	dp[b] = 1
for i in range(1, n + 1):
	if dp[i] == 0:
		index = i
		break
if index != -1:
	print(n - 1)
	for i in range(1, n + 1):
		if i != index:
			print(i, index)
else:
	print(n - 1)
	for i in range(1, n + 1):
		if i != 1:
			print(i, 1)


(n, m) = map(int, input().split())
pairs = set()
for i in range(m):
	(u, v) = map(int, input().split())
	pairs.add(u)
	pairs.add(v)
center = None
for i in range(1, n + 1):
	if i not in pairs:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != center:
		print(center, i)


from sys import stdin, stdout

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		(n, m) = [int(x) for x in R().split()]
		check = {}
		node = 1
		for i in range(m):
			(x, y) = [int(tmp) for tmp in R().split()]
			check[x] = check[y] = True
			if node in check:
				for j in range(node + 1, n + 1):
					if j not in check:
						node = j
						break
		ans.append(str(n - 1))
		for i in range(1, n + 1):
			if i != node:
				ans.append(str(i) + ' ' + str(node))
		W('\n'.join(ans))

def main():
	s = SOLVE()
	s.solve()
main()


(n, m) = map(int, input().split())
l = [0] * n
for i in range(m):
	(a, b) = map(int, input().split())
	l[a - 1] = 1
	l[b - 1] = 1
for i in range(n):
	if l[i] == 0:
		k = i
		break
print(n - 1)
for i in range(n):
	if i != k:
		print(k + 1, i + 1)


f = None
if f:
	input = f.readline
args = input().split()
n = int(args[0])
m = int(args[1])
cities = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
	args = input().split()
	a = int(args[0]) - 1
	b = int(args[1]) - 1
	cities[a][b] = -1
	cities[b][a] = -1
for i in range(n):
	apply_ = True
	for j in range(n):
		if j != i and cities[i][j] == -1:
			apply_ = False
			break
	if apply_:
		print(n - 1)
		for j in range(n):
			if i != j:
				print(i + 1, j + 1)
		break


(m, n) = list(map(int, input().split()))
another = [0 for i in range(m)]
for i in range(n):
	(to_, from_) = list(map(int, input().split()))
	another[to_ - 1] += 1
	another[from_ - 1] += 1
pairs = []
count = 0
middle = another.index(min(another)) + 1
print(m - 1)
for i in range(m):
	if i == middle - 1:
		pass
	else:
		print(i + 1, middle)


(n, m) = map(int, input().split())
lis = []
con = [0] * 1001
ans = 0
for i in range(m):
	(a, b) = map(int, input().split())
	lis.append([a, b])
	con[a] += 1
	con[b] += 1
for i in range(1, n + 1):
	if con[i] == 0:
		ans = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != ans:
		print(ans, i)


(n, m) = map(int, input().split())
l = [0] * n
for i in range(m):
	(a, b) = map(int, input().split())
	l[a - 1] = 1
	l[b - 1] = 1
V = l.index(0) + 1
print(n - 1)
for i in range(1, n + 1):
	if i != V:
		print(V, i)


(n, m) = map(int, input().split())
restrictions = {i for i in range(1, n + 1)}
roads = set()
for _ in range(m):
	(x, y) = map(int, input().split())
	roads.add(x)
	roads.add(y)
roads = restrictions - roads
if roads == {}:
	print(-1)
else:
	central = roads.pop()
	print(n - 1)
	for i in range(1, n + 1):
		if i != central:
			print(central, i)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, m) = iia()
d1 = set()
for i in range(m):
	(a, b) = iia()
	d1.add(a)
	d1.add(b)
cur = (set(list(range(1, n + 1))) - d1).pop()
print(n - 1)
for i in range(1, n + 1):
	if i != cur:
		print(cur, i)


(n, k) = map(int, input().split())
no_path = []
for _ in range(k):
	no_path.append(list(map(int, input().split())))
res = []
t = [1 for i in range(n + 1)]
node = None
for i in no_path:
	t[i[0]] = 0
	t[i[1]] = 0
for i in range(1, n + 1):
	if t[i] == 1:
		node = i
		break
for i in range(1, n + 1):
	if i != node:
		res.append([i, node])
print(len(res))
for i in res:
	print(*i)


(n, m) = list(map(int, input().split()))
not_poss = [list(map(int, input().split())) for i in range(m)]
u = set()
for j in not_poss:
	u = u | set(j)
for k in range(1, n + 1):
	if k not in u:
		print(n - 1)
		for j in range(1, n + 1):
			if j != k:
				print(j, k)
		exit()


(n, m) = map(int, input().strip().split())
used = [False] * (n + 1)
for _ in range(m):
	(u, v) = map(int, input().strip().split())
	(used[u], used[v]) = (True, True)
s = -1
for i in range(1, n + 1):
	if not used[i]:
		s = i
		break
print(n - 1)
for i in range(1, n + 1):
	if s != i:
		print(i, s)


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())

def solve(n, mat):
	temp = n
	while temp in mat:
		temp -= 1
	print(n - 1)
	for i in range(1, n + 1):
		if i != temp:
			print(temp, i)
mat = []
(n, m) = get_int()
for _ in range(m):
	mat += int_arr()
solve(n, mat)


(n, k) = map(int, input().split())
nodes = [1] * (n + 1)
for i in range(k):
	(x, y) = map(int, input().split())
	nodes[x] = 0
	nodes[y] = 0
ans = []
first = -1
for i in range(1, n + 1):
	if nodes[i] == 1:
		first = i
		break
for i in range(1, n + 1):
	if i == first:
		continue
	ans.append((first, i))
print(len(ans))
for i in ans:
	print(i[0], i[1])


(n, m) = map(int, input().split())
mp = {}
for i in range(m):
	(x, y) = map(int, input().strip().split())
	mp[x] = 1
	mp[y] = 1
x = 0
for i in range(n):
	if i + 1 not in mp:
		x = i
		break
ans = []
for i in range(n):
	if i != x:
		ans.append([x + 1, i + 1])
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


s = input().split()
n = int(s[0])
m = int(s[1])
l = []
for i in range(m):
	s = input().split()
	l.append(int(s[0]))
	l.append(int(s[1]))
l.sort()
star = 1
for x in l:
	if x == star:
		star += 1
print(n - 1)
for i in range(n):
	if i + 1 != star:
		print(str(star) + ' ' + str(i + 1))


def main():
	(n, m) = map(int, input().split())
	ch = [True] * (n + 1)
	for i in range(m):
		(a, b) = map(int, input().split())
		(a, b) = (a - 1, b - 1)
		ch[a] = ch[b] = False
	cen = ch.index(True) + 1
	print(n - 1)
	for i in range(1, n + 1):
		if i == cen:
			continue
		print(cen, i)
main()


(n, m) = map(int, input().split())
legalRoads = set([i + 1 for i in range(n)])
for i in range(m):
	(a, b) = map(int, input().split())
	if a in legalRoads:
		legalRoads.remove(a)
	if b in legalRoads:
		legalRoads.remove(b)
cenRoad = legalRoads.pop()
print(n - 1)
for i in range(n):
	if i + 1 != cenRoad:
		print(cenRoad, i + 1)


import sys
sys.setrecursionlimit(10 ** 7)
from collections import deque
import math
(n, m) = [int(x) for x in input().split()]
root = 0
canberoot = [True] * (n + 1)
for _ in range(m):
	(a, b) = [int(x) for x in input().split()]
	canberoot[a] = False
	canberoot[b] = False
for i in range(1, n + 1):
	if canberoot[i]:
		root = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != root:
		print(root, i)


(n, m) = [int(x) for x in input().split()]
forbidden = set()
for i in range(m):
	(a, b) = [int(x) for x in input().split()]
	forbidden.add(a)
	forbidden.add(b)
for i in range(1, n + 1):
	if i not in forbidden:
		print(n - 1)
		for j in range(1, n + 1):
			if j != i:
				print(j, i)
		exit()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import log2, ceil, floor
(n, m) = map(int, input().split())
s = set()
t = [i for i in range(1, n + 1)]
t = set(t)
for i in range(m):
	(u, v) = map(int, input().split())
	s.add(u)
	s.add(v)
u = list(t - s)
var = u[0]
print(n - 1)
for i in range(1, n + 1):
	if i == var:
		continue
	print(i, var)


f = lambda : input()
(n, m) = list(map(int, f().split()))
cc = [0] * (n + 1)
for i in range(m):
	(a, b) = list(map(int, f().split()))
	cc[a] += 1
	cc[b] += 1
center = 0
for i in range(1, n + 1):
	if cc[i] == 0:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != center:
		print(i, center)


(n, m) = map(int, input().strip().split())
shouldNotConnect = [tuple(map(int, input().strip().split())) for _ in range(m)]
notInM = None
has = set()
for (na, nb) in shouldNotConnect:
	has.add(na)
	has.add(nb)
for i in range(1, n + 1):
	if i not in has:
		notInM = i
		break
ans = []
start = 1
for i in range(1, n + 1):
	if start != notInM:
		ans += [(start, notInM)]
	start += 1
print(len(ans))
for (a, b) in ans:
	print(a, b)


z = lambda : map(int, input().split())
(a, b) = z()
s = set(range(1, a + 1))
for _ in ' ' * b:
	s -= set(z())
s = next(iter(s))
print(a - 1)
[print(s, i) for i in range(1, a + 1) if i != s]


(n, m) = map(int, input().rstrip().split())
z = [0] * (n + 1)
for i in range(m):
	(x, y) = map(int, input().rstrip().split())
	z[x] = 1
	z[y] = 1
start = z[1:].index(0) + 1
print(n - 1)
for i in range(1, n + 1):
	if i != start:
		print(start, i)


(n, m) = map(int, input().split())
ban = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

def get_min_node_count(ban_count):
	mn_count = float('inf')
	mn_node = None
	for (node, count) in enumerate(ban_count):
		if count < mn_count:
			mn_node = node
			mn_count = count
	return (mn_node, mn_count)

def solve(ban, n, m):
	ban_count = [0] * n
	for (a, b) in ban:
		ban_count[a] += 1
		ban_count[b] += 1
	(mn_node, mn_count) = get_min_node_count(ban_count)
	return [(mn_node, i) for i in range(n) if i != mn_node]
res = solve(ban, n, m)
print(len(res))
for (a, b) in res:
	print(a + 1, b + 1)


(n, m) = map(int, input().split(' '))
a = set([i for i in range(1, n + 1)])
for i in range(m):
	(p, q) = map(int, input().split(' '))
	if p in a:
		a.remove(p)
	if q in a:
		a.remove(q)
ans = a.pop()
print(n - 1)
for i in range(1, n + 1):
	if not i == ans:
		print(ans, i)


(n, m) = list(map(int, input().split()))
dx = []
dy = []
for i in range(0, m):
	(a, b) = list(map(int, input().split()))
	dx.append(a - 1)
	dy.append(b - 1)
c = []
for i in range(0, n):
	c.append(0)
for i in range(0, m):
	c[dx[i]] = c[dx[i]] + 1
	c[dy[i]] = c[dy[i]] + 1
p = 0
for i in range(0, n):
	if c[i] == 0:
		p = i
		break
print(n - 1)
for i in range(0, n):
	if i != p:
		print(p + 1, i + 1)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(0)
for t in range(m):
	(a, b) = map(int, input().split())
	l[a - 1] = -1
	l[b - 1] = -1
for y in range(len(l)):
	if l[y] != -1:
		o = y
		break
print(n - 1)
for t in range(n):
	if t != o:
		print(t + 1, o + 1)


g = input()
(n, m) = [int(x) for x in g.split()]
li = []
for i in range(n + 1):
	li.append(0)
for j in range(m):
	t = input()
	(n1, m1) = [int(x) for x in t.split()]
	li[n1] = 1
	li[m1] = 1
for k in range(1, n + 1):
	if li[k] == 0:
		break
print(n - 1)
for h in range(n):
	if h + 1 != k:
		print(k, h + 1)


def main():
	(n, m) = [int(x) for x in input().split()]
	possible_nodes = [True for _ in range(n)]
	for _ in range(m):
		(u, v) = [int(x) - 1 for x in input().split()]
		possible_nodes[u] = False
		possible_nodes[v] = False
	print(n - 1)
	for i in range(n):
		if possible_nodes[i]:
			for j in range(n):
				if i != j:
					print(f'{i + 1} {j + 1}')
			break
main()


impassable = []
(n, m) = map(int, input().split())
for i in range(m):
	impassable.extend(list(map(int, input().split())))
center_candidates = [x for x in range(1, n + 1) if x not in impassable]
center = center_candidates[0]
print(n - 1)
for x in range(1, n + 1):
	if x != center:
		print(center, x)


(n, m) = map(int, input().split())
k = []
for i in range(m):
	(a, b) = map(int, input().split())
	k.append(a)
	k.append(b)
for i in range(1, n + 1):
	if i not in k:
		centr = i
print(n - 1)
for i in range(1, n + 1):
	if i != centr:
		print(i, centr)


def main():
	from sys import stdin, stdout
	(n, m) = map(int, stdin.readline().split())
	start_not = set()
	for _ in range(m):
		(a, b) = map(int, stdin.readline().split())
		start_not.add(a - 1)
		start_not.add(b - 1)
	visited = [False for _ in range(n)]
	for i in range(n):
		if i not in start_not:
			center = i
			break
	stdout.write(str(n - 1) + '\n')
	for i in range(n):
		if i != center:
			stdout.write(str(center + 1) + ' ' + str(i + 1) + '\n')
main()


(n, m) = list(map(int, input().split(' ')))
check = [0] * (n + 1)
check[0] = -1
for x in range(m):
	(a, b) = list(map(int, input().split(' ')))
	check[a] = 1
	check[b] = 1
print(n - 1)
i = 1
res = check.index(0)
while i <= n:
	if i == res:
		i += 1
		continue
	print(res, i)
	i += 1


(n, m) = map(int, input().split())
L = [0] * n
for i in range(m):
	(a, b) = map(int, input().split())
	L[a - 1] = -1
	L[b - 1] = -1
central = 0
for i in range(n):
	if L[i] == 0:
		central = i + 1
		break
print(n - 1)
for i in range(1, n + 1):
	if i != central:
		print(central, i)


(n, m) = map(int, input().split())
dic = {}
s = set()
s1 = set()
for i in range(1, n + 1):
	s.add(i)
for _ in range(m):
	(a, b) = map(int, input().split())
	s1.add(a)
	s1.add(b)
for i in s1:
	if i in s:
		s.remove(i)
for i in s:
	k = i
	break
print(n - 1)
if n - 1 > 0:
	for i in range(1, n + 1):
		if i != k:
			print(k, i)


(n, m) = map(int, input().split())
tmp = list(range(1, n + 1))
for i in range(m):
	(y, x) = map(int, input().split())
	if x in tmp:
		tmp.pop(tmp.index(x))
	if y in tmp:
		tmp.pop(tmp.index(y))
print(n - 1)
l = tmp[0]
for i in range(1, n + 1):
	if l != i:
		print(i, l)


def inp():
	return map(int, stdin.readline().split())

class graph:

	def __init__(self, gdict=None):
		if gdict is None:
			gdict = defaultdict(list)
		self.gdict = gdict

	def edges(self):
		return self.find_edges()

	def find_edges(self):
		edges = []
		for node in self.gdict:
			for nxNode in self.gdict[node]:
				if {nxNode, node} not in edges:
					edges.append({node, nxNode})
		return edges

	def get_vertices(self):
		return list(self.gdict.keys())

	def add_vertix(self, node):
		self.gdict[node] = []

	def add_edge(self, node1, node2):
		self.gdict[node1].append(node2)
from collections import *
from sys import *

def main():
	g = graph()
	(n, m) = inp()
	(dic, m1) = (defaultdict(int), 0)
	for i in range(m):
		(a, b) = inp()
		(dic[a], dic[b]) = (1, 1)
	for i in range(1, n + 1):
		if not dic[i]:
			m1 = i
			break
	for i in range(1, n + 1):
		if i != m1:
			g.add_edge(i, m1)
	print(len(g.edges()))
	for i in g.edges():
		print(*i)
main()


(n, m) = map(int, input().split())
lst = list(range(1, n + 1))
for i in range(m):
	(a, b) = map(int, input().split())
	if a in lst:
		lst.remove(a)
	if b in lst:
		lst.remove(b)
x = lst[0]
print(n - 1)
for i in range(1, n + 1):
	if i != x:
		print(x, i)


(n, m) = map(int, input().split())
l = []
d = {}
for i in range(1, n + 1):
	d[i] = 1
for i in range(m):
	(c, e) = map(int, input().split())
	d[c] = 0
	d[e] = 0
for i in d:
	if d[i] != 0:
		print(n - 1)
		for j in range(1, n + 1):
			if i != j:
				print(i, j)
		break


(n, m) = [int(i) for i in input().split()]
s = set()
for i in range(m):
	s |= set(input().split())
x = (set([str(i) for i in range(1, n + 1)]) - s).pop()
print(n - 1)
for i in range(1, n + 1):
	if str(i) != x:
		print('%s %s' % (x, i))


class CodeforcesTask330BSolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.constraints = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		for x in range(self.n_m[1]):
			self.constraints.append([int(y) for y in input().split(' ')])

	def process_task(self):
		poss = set([x + 1 for x in range(self.n_m[0])])
		for cons in self.constraints:
			if cons[0] in poss:
				poss.remove(cons[0])
			if cons[1] in poss:
				poss.remove(cons[1])
		chosen = poss.pop()
		result = []
		for x in range(self.n_m[0]):
			if x + 1 != chosen:
				result.append('{0} {1}'.format(chosen, x + 1))
		self.result = '{0}\n{1}'.format(self.n_m[0] - 1, '\n'.join(result))

	def get_result(self):
		return self.result
Solution = CodeforcesTask330BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, m) = map(int, input().split())
s = set()
for i in range(1, n + 1):
	s.add(i)
for i in range(m):
	(u, v) = map(int, input().split())
	if u in s:
		s.remove(u)
	if v in s:
		s.remove(v)
print(n - 1)
x = list(s)[0]
for i in range(1, n + 1):
	if x != i:
		print(x, i)


(n, m) = list(map(int, input().split()))
arr = []
for i in range(m):
	(x, y) = list(map(int, input().split()))
	arr.append(x)
	arr.append(y)
print(n - 1)
for i in range(1, n + 1):
	if (i in arr) == False:
		for j in range(1, n + 1):
			if i != j:
				print(str(i) + ' ' + str(j))
		break


(n, m) = map(int, input().split())
x = [0] * n
for i in range(m):
	(a, b) = map(int, input().split())
	x[a - 1] = x[b - 1] = 1
p = -1
for i in range(n):
	if x[i] == 0:
		p = i + 1
		break
print(n - 1)
for i in range(n):
	if i + 1 != p:
		print(p, i + 1)


from bisect import bisect_left

def main():
	(n, m) = list(map(int, input().split()))
	s = set(range(1, n + 1))
	for i in range(m):
		s -= set(list(map(int, input().split())))
	s = list(s)[0]
	print(n - 1)
	for i in range(1, n + 1):
		if i != s:
			print(i, s)
main()


(n, m) = map(int, input().split())
nos = set()
for i in range(m):
	(a, b) = map(int, input().split())
	nos.add(a)
	nos.add(b)
cidade = 1
flag = False
indice = 1
while not flag and indice < n + 1:
	if indice not in nos:
		cidade = indice
		flag = True
	indice += 1
print(n - 1)
for i in range(1, n + 1):
	if i != cidade:
		print(i, cidade)


(n, m) = map(int, input().split())
l = []
a1 = set(range(1, n + 1))
for i in range(m):
	(c, d) = map(int, input().split())
	l += [c]
	l += [d]
a2 = set(l)
a3 = list(a1 - a2)
a4 = a3[0]
print(n - 1)
for i in range(1, n + 1):
	if i != a4:
		print(a4, i)
	else:
		pass


import sys
import math
import random
if len(sys.argv) >= 2:
	if sys.argv[1] == 'LOCAL':
		sys.stdin = open('input.in', 'r')
(n, m) = map(int, input().split())
l = [0] * (n + 1)
i = 1
while i <= m:
	(ai, bi) = map(int, input().split())
	l[ai] += 1
	l[bi] += 1
	i += 1
root = []
i = 1
while i <= n:
	if l[i] == 0:
		root.append(i)
	i += 1
print(n - 1)
root = root[0]
i = 1
while i <= n:
	if root != i:
		print(root, i)
	i += 1


(n, m) = map(int, input().split())
st = set(range(1, n + 1))
for i in range(m):
	(u, v) = map(int, input().split())
	st.discard(u)
	st.discard(v)
center = st.pop()
print(n - 1)
for i in range(1, n + 1):
	if i != center:
		print(i, center)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
f = [-1] * (n + 1)
u = {}
for j in range(m):
	(a, b) = map(int, input().split())
	u[a] = 1
	u[b] = 1
	f[a] = b
	f[b] = a
x = -1
for j in range(1, n + 1):
	if j not in u:
		x = j
		break
d = []
for j in range(1, n + 1):
	if j != x:
		d.append([x, j])
print(len(d))
for j in d:
	print(*j)


(numberOfcities, nBlocked) = [int(item) for item in input().split()]
blocked = set()
for i in range(nBlocked):
	(n, m) = [int(item) for item in input().split()]
	blocked.add(n)
	blocked.add(m)
point = 0
for k in range(1, numberOfcities + 1):
	if k not in blocked:
		point = k
		break
print(numberOfcities - 1)
for k in range(1, numberOfcities + 1):
	if k != point:
		print(point, k)


(limite, num_linhas) = map(int, input().split())
pares = [0] * (limite + 1)
for i in range(num_linhas):
	(cidade_a, cidade_b) = map(int, input().split())
	pares[cidade_a] = 1
	pares[cidade_b] = 1
for i in range(1, limite + 1):
	if pares[i] == 0:
		aux = i
		break
print(limite - 1)
for i in range(1, limite + 1):
	if i != aux:
		print(i, aux)


(n, m) = map(int, input().split())
aux = []
for i in range(m):
	(a, b) = map(int, input().split())
	if a not in aux:
		aux.append(a)
	if b not in aux:
		aux.append(b)
for i in range(1, n + 1):
	if i not in aux:
		z = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != z:
		print(z, i)


(n, k) = list(map(int, input().split()))
arr = [k for k in range(1, n + 1)]
arr2 = arr.copy()
for _ in range(k):
	(a, b) = list(map(int, input().split()))
	if a in arr:
		arr.remove(a)
	if b in arr:
		arr.remove(b)
z = arr[0]
arr2.remove(z)
print(n - 1)
for kk in arr2:
	print(z, kk)


(n, m) = map(int, input().split())
neighbors = [True for i in range(1 + n)]
for i in range(m):
	(u, v) = map(int, input().split())
	neighbors[u] = False
	neighbors[v] = False
solution = []

def main():
	for i in range(1, 1 + n):
		if neighbors[i] == True:
			for j in range(1, 1 + n):
				if i != j:
					solution.append((i, j))
			return
main()
print(len(solution))
for i in range(len(solution)):
	(p, k) = solution[i]
	print(p, k)


(n, m) = map(int, input().split())
visited = [0] * (n + 1)
for _ in range(m):
	(x, y) = map(int, input().split())
	visited[x] = 1
	visited[y] = 1
for i in range(1, n + 1):
	if visited[i] == 0:
		hub = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i == hub:
		continue
	else:
		print(hub, i)


def proB(n, arr):
	graph = {}
	for i in range(n):
		graph[i + 1] = i + 1
	non = []
	for i in arr:
		non.append(i[0])
		non.append(i[1])
	for i in graph:
		if i in non:
			continue
		head = i
		break
	for i in graph:
		graph[i] = head
	print(n - len(non) - 1 + len(non))
	for (i, j) in graph.items():
		if i == j:
			continue
		print(i, j)
arr = list(map(int, input().split()))
(n, m) = arr
arr = []
for i in range(m):
	arr1 = list(map(int, input().split()))
	arr.append(arr1)
proB(n, arr)


(n, m) = map(int, input().split())
arr = [0 for i in range(n + 1)]
for i in range(m):
	(a, b) = map(int, input().split())
	arr[a] = a
	arr[b] = b
print(n - 1)
centroid = 0
for i in range(1, n + 1):
	if arr[i] == 0:
		centroid = i
		break
for i in range(1, n + 1):
	if i is not centroid:
		print(i, '', centroid)


(n, m) = map(int, input().split())
ls = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
	(a, b) = map(int, input().split())
	ls[a - 1][b - 1] = -1
	ls[b - 1][a - 1] = -1
flag = False
for i in range(n):
	if sum(ls[i]) == 0:
		flag = True
		k = i
if flag:
	print(n - 1)
	for i in range(n):
		if k != i:
			print(i + 1, k + 1)


a = input().split()
n = int(a[0])
m = int(a[1])
v = [i for i in range(1, n + 1)]
for i in range(m):
	b = input().split()
	v[int(b[0]) - 1] = 0
	v[int(b[1]) - 1] = 0
for i in range(n):
	if v[i] != 0:
		print(n - 1)
		for j in range(n):
			if j != i:
				print(i + 1, j + 1)
		exit()


(n, m) = (int(_) for _ in input().split())
v = [True] * n
for i in range(m):
	(a, b) = (int(_) for _ in input().split())
	v[a - 1] = v[b - 1] = False
k = -1
for i in range(n):
	if v[i]:
		k = i
		break
print(n - 1)
for i in range(n):
	if i != k:
		print(i + 1, k + 1)


import sys

def get_ints():
	return map(int, sys.stdin.readline().split())
(n, m) = get_ints()
a = [0] * (n + 1)
for _ in range(m):
	(x, y) = get_ints()
	a[x] += 1
	a[y] += 1
j = -2
for i in range(1, n + 1):
	if a[i] == 0:
		j = i
		break
print(n - 1)
for q in range(1, n + 1):
	if q == j:
		continue
	print(j, q)


N = M = ARR = None

def entrypoint():
	global N, M, ARR
	(N, M) = list(map(int, input().split()))
	ARR = [True] * (N + 1)
	ARR[0] = False
	for _ in range(M):
		(a, b) = list(map(int, input().split()))
		ARR[a] = False
		ARR[b] = False

def process():
	first_true = ARR.index(True)
	print(N - 1)
	for i in range(1, N + 1):
		if first_true == i:
			continue
		print(i, end=' ' + str(first_true) + '\n')

def main():
	entrypoint()
	process()
main()


d = [0] * 1000
(n, m) = list(map(int, input().split()))
for i in range(m):
	(u, v) = list(map(int, input().split()))
	d[u - 1] = 1
	d[v - 1] = 1
for i in range(n):
	if d[i] == 0:
		c = i
		break
print(n - 1)
for i in range(n):
	if i == c:
		continue
	print(c + 1, i + 1)


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
arr = get_ints()
n = arr[0]
m = arr[1]
dicts = {}
for i in range(m):
	temparr = get_ints()
	ii = temparr[0]
	jj = temparr[1]
	if ii not in dicts:
		dicts[ii] = 1
	if jj not in dicts:
		dicts[jj] = 1
middle = 0
for i in range(1, n + 1):
	if i not in dicts:
		middle = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i == middle:
		continue
	print(str(i) + ' ' + str(middle))


from sys import stdin, stdout
from os import path
rd = lambda : stdin.readline().strip()
wr = stdout.write
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
import time, math
(x, y) = map(int, rd().split())
myDict = []
vis = [0] * (x + 1)
for _ in range(y):
	(n, m) = map(int, rd().split())
	myDict.append(n)
	myDict.append(m)
for val in myDict:
	vis[val] = 1
value = vis[1:].index(0) + 1
print(x - 1)
for i in range(1, x + 1):
	if i != value:
		print(value, i)


(n, m) = map(int, input().split())
ls = []
for _ in range(m):
	(a, b) = map(int, input().split())
	ls.append(a)
	ls.append(b)
for i in range(1, n + 1):
	if i not in ls:
		k = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != k:
		print(i, k)


(n, m) = map(int, input().split())
hash = set()
for i in range(m):
	(a, b) = map(int, input().split())
	hash.add(a)
	hash.add(b)
count = 0
ans = []
if n > 3:
	for i in range(1, n + 1):
		if i not in hash:
			ans.append(i)
			count += 1
		if count == 3:
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i not in ans and len(ans) >= 2:
			print(ans[1], i)
		elif i not in ans and len(ans) == 1:
			print(ans[0], i)
	if len(ans) == 2:
		print(ans[0], ans[1])
	if len(ans) > 2:
		print(ans[0], ans[1])
		print(ans[1], ans[2])
if n <= 3:
	print(n - 1)
	if n != 1:
		if n == 3:
			if 1 in hash and 3 in hash:
				print(1, 2)
				print(2, 3)
			elif 1 in hash and 2 in hash:
				print(1, 3)
				print(2, 3)
			elif 2 in hash and 3 in hash:
				print(2, 1)
				print(1, 3)
			else:
				print(1, 2)
				print(1, 3)
		elif n == 2:
			print(1, 2)


def roadConstruction():
	(n, m) = map(int, input().split())
	lst = [[0 for i in range(n)] for j in range(n)]
	for i in range(m):
		(u, v) = map(int, input().split())
		lst[u - 1][v - 1] = -1
		lst[v - 1][u - 1] = -1
	flag = False
	for i in range(n):
		if sum(lst[i]) == 0:
			flag = True
			centralNode = i
	if flag:
		print(n - 1)
		for i in range(n):
			if centralNode != i:
				print(i + 1, centralNode + 1)
roadConstruction()


(n, m) = list(map(int, input().split()))
e = []
nc = []
for i in range(0, n + 1):
	nc.append(0)
for i in range(0, m):
	(u, v) = list(map(int, input().split()))
	e.append([u, v])
	nc[u] += 1
	nc[v] += 1
c = -1
for i in range(1, n + 1):
	if nc[i] == 0:
		c = i
print(n - 1)
for i in range(1, n + 1):
	if i != c:
		print(i, c)


import sys

def solution(a, b):
	return 1

def main():
	(n, m) = map(int, sys.stdin.readline().strip().split(' '))
	cant = [0] * n
	for _ in range(m):
		(a, b) = map(int, sys.stdin.readline().strip().split(' '))
		cant[a - 1] = 1
		cant[b - 1] = 1
	print(n - 1)
	for i in range(n):
		if cant[i] == 0:
			for k in range(n):
				if i != k:
					print(i + 1, k + 1)
			break
main()


(n, m) = [int(x) for x in input().split()]
pairs = []
for _ in range(m):
	pairs.append([int(x) for x in input().split()])
nodes = [x for x in range(1, n + 1)]
temp = [c for c in nodes]
for p in pairs:
	if p[0] in temp:
		temp.remove(p[0])
	if p[1] in temp:
		temp.remove(p[1])
print(n - 1)
s = temp[0]
for c in nodes:
	if c == s:
		continue
	else:
		print(s, c)


(n, v) = map(int, input().split())
k = []
for i in range(v):
	(a, b) = map(int, input().split())
	k.append(a)
	k.append(b)
print(n - 1)
for i in range(1, n + 1):
	if i not in k:
		center = i
for i in range(1, n + 1):
	if i != center:
		print(i, center)


inp = lambda : [*map(int, input().split())]
(n, m) = inp()
f = [True] * (n + 1)
for i in range(m):
	(x, y) = inp()
	f[x] = False
	f[y] = False
for i in range(1, n + 1):
	if f[i]:
		root = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != root:
		print(root, i)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		(n, m) = invr()
		a = [0 for _ in range(n)]
		for _ in range(m):
			(x, y) = invr()
			a[x - 1] = 1
			a[y - 1] = 1
		print(n - 1)
		for i in range(n):
			if a[i] == 0:
				v = i + 1
				break
		for i in range(1, n + 1):
			if v != i:
				print(v, i)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m) = map(int, input().split())
restricted_with = [[] for i in range(n)]
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	restricted_with[a].append(b)
	restricted_with[b].append(a)
for (i, l) in enumerate(map(len, restricted_with)):
	if l == 0:
		print(n - 1)
		for e in range(n):
			if i != e:
				print(i + 1, e + 1)
		break


def main():
	(n, m) = map(int, input().split(' '))
	c = [0 for i in range(n)]
	e = []
	for i in range(m):
		(ai, bi) = map(int, input().split(' '))
		c[ai - 1] += 1
		c[bi - 1] += 1
		e.append((ai - 1, bi - 1))
	center = None
	for (i, ci) in enumerate(c):
		if ci == 0:
			center = i
			break
	assert center != None
	print(n - 1)
	for i in range(n):
		if i == center:
			continue
		print('{} {}'.format(i + 1, center + 1))
main()


import sys
sys.setrecursionlimit(10000)
(n, m) = [int(x) for x in sys.stdin.readline().strip().split()]
index = 1
s = set(range(1, n + 1))
for i in range(m):
	k = {int(x) for x in sys.stdin.readline().strip().split()}
	s = s - k
l = list(s)[0]
print(n - 1)
for i in range(1, n + 1):
	if i != l:
		print(l, i)


(n, m) = map(int, input().split())
g = {}
for _ in range(m):
	(x, y) = map(int, input().split())
	if x in g:
		g[x] += 1
	else:
		g[x] = 1
	if y in g:
		g[y] += 1
	else:
		g[y] = 1
var = 0
for i in range(1, n + 1):
	if i not in g:
		var = i
print(n - 1)
for i in range(1, n + 1):
	if i != var:
		print(var, i)


def roadCostruction(n, m):
	cidades = [list(map(int, input().split())) for _ in range(m)]
	pares = [[True for j in range(n + 1)] for i in range(n + 1)]
	for x in cidades:
		pares[x[0]][x[1]] = False
		pares[x[1]][x[0]] = False
	parprovavel = -1
	for i in range(1, n + 1):
		aux = True
		for j in range(1, n + 1):
			aux &= pares[i][j]
			if not aux:
				break
		if aux:
			parprovavel = i
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i != parprovavel:
			print(i, parprovavel)
(n, m) = map(int, input().split())
roadCostruction(n, m)


(n, m) = map(int, input().split())
e = [[1 for i in range(n)] for i in range(n)]
l = [0] * n
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	l[a] = 1
	l[b] = 1
center = -1
for i in range(n):
	if l[i] == 0:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i == center + 1:
		continue
	print(i, center + 1, sep=' ')


(n, m) = map(int, input().split())
arr = [False] * (n + 1)
for i in range(m):
	(a, b) = map(int, input().split())
	arr[a] = arr[b] = True
i = 1
while i < n + 1 and arr[i]:
	i += 1
print(n - 1)
for j in range(1, n + 1):
	if j != i:
		print(i, j)


(n, m) = map(int, input().split())
g = [0] * (n + 1)
for k in range(m):
	(a, b) = map(int, input().split())
	g[a] = 1
	g[b] = 1
c = 0
for k in range(1, len(g)):
	if g[k] == 0:
		c = k
		break
print(n - 1)
for k in range(1, len(g)):
	if k == c:
		continue
	print(c, k)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
(n, m) = map(int, input().split())
done = defaultdict(lambda : False)
for _ in range(m):
	(a, b) = map(int, input().split())
	done[a] = True
	done[b] = True
for i in range(1, n + 1):
	if not done[i]:
		print(n - 1)
		for j in range(1, n + 1):
			if j != i:
				print(i, j)
		break


def main():
	(n, m) = map(int, input().split())
	l = [True] * (n + 1)
	l[0] = False
	for _ in range(m):
		(a, b) = map(int, input().split())
		l[a] = l[b] = False
	center = l.index(True)
	print(n - 1)
	for i in range(1, center):
		print(center, i)
	for i in range(center + 1, n + 1):
		print(center, i)

def __starting_point():
	main()
__starting_point()


__author__ = 'Rajan'
(n, m) = map(int, input().split())
hash = [False for i in range(n + 1)]
for i in range(m):
	(a, b) = map(int, input().split())
	hash[a] = hash[b] = True
b = 0
for i in range(1, n + 1):
	if not hash[i]:
		b = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != b:
		print(i, b)


(n, m) = list(map(int, input().rstrip().split()))
a = []
b = []
li = [0] * (n + 1)
li[0] = 1
for _ in range(m):
	x = list(map(int, input().rstrip().split()))
	a += [x[0]]
	b += [x[1]]
	li[x[0]] = 1
	li[x[1]] = 1
for i in range(1, n + 1):
	if li[i] != 1:
		x = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != x:
		print(i, x)


(n, m) = map(int, input().split())
jhagda = set()
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	jhagda.add(a)
	jhagda.add(b)
centre = -1
for i in range(n):
	if i not in jhagda:
		centre = i
		break
print(n - 1)
for i in range(n):
	if i != centre:
		print(i + 1, centre + 1)


I = lambda : map(int, input().split())
(n, m) = I()
X = set(range(1, n + 1))
for _ in range(m):
	X -= set(I())
x = X.pop()
print(n - 1)
for i in range(1, n + 1):
	if i != x:
		print(i, x)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
(n, m) = rinput()
visited = [True] * (n + 1)
for _ in range(m):
	(u, v) = rinput()
	visited[u] = False
	visited[v] = False
for i in range(1, n + 1):
	if visited[i]:
		break
print(n - 1)
for j in range(1, n + 1):
	if j != i:
		print(i, j)


from sys import *
from math import *
from sys import stdin, stdout
from collections import *
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
(n, m) = get_int()
lst = []
for i in range(m):
	arr = int_arr()
	lst += [arr[0]] + [arr[1]]
ct = n
while ct in lst:
	ct -= 1
print(n - 1)
for i in range(1, n + 1):
	if i != ct:
		print(ct, i)


(n, m) = map(int, input().split())
d = {}
for i in range(m):
	(a, b) = map(int, input().split())
	d[a] = 1
	d[b] = 1
nu = 0
for i in range(1, n + 1):
	if i not in d:
		nu = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != nu:
		print(i, nu)


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	(n, m) = cin()
	d = {}
	for i in range(m):
		(j, k) = cin()
		d[j] = 1
		d[k] = 1
	for i in range(1, n + 1):
		if i not in d:
			x = i
			break
	print(n - 1)
	for i in range(1, n + 1):
		if x != i:
			print(i, x)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


(cities, pairs) = map(int, input().split())
road1 = {}
road2 = {}
if pairs == 0:
	print(cities - 1)
	for i in range(2, cities + 1):
		print(1, i)
else:
	for i in range(pairs):
		(u, v) = map(int, input().split())
		road1[u] = v
		road2[v] = u
	print(cities - 1)
	k = 0
	for j in range(1, cities + 1):
		if j not in road1 and j not in road2:
			k = j
			break
	for j in range(1, cities + 1):
		if j == k:
			continue
		else:
			print(k, j)


from sys import stdin

def make(first, second):
	return str(first) + ' ' + str(second)
(n, m) = list(map(int, stdin.readline().split()))
no_chance = dict()
for _ in range(m):
	(first, second) = list(map(int, stdin.readline().split()))
	if first > second:
		(first, second) = (second, first)
	no_chance[make(first, second)] = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		ii = i
		jj = j
		if ii > jj:
			(ii, jj) = (jj, ii)
		if make(ii, jj) in no_chance:
			break
	else:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i == center:
		pass
	else:
		print(i, center)


(n, m) = map(int, input().split())
I = []
for i in range(n):
	I.append(i + 1)
for i in range(m):
	(a, b) = map(int, input().split())
	if a in I:
		I.remove(a)
	if b in I:
		I.remove(b)
f = I[0]
print(n - 1)
for i in range(n):
	if i + 1 != f:
		print(f, i + 1)


not_possible = []
(cities, num_not_possible) = [int(x) for x in input().split()]
middle = 1
for i in range(num_not_possible):
	string = [int(x) for x in input().split()]
	if string[0] == middle:
		middle += 1
	if string[1] == middle:
		middle += 1
	not_possible.append((string[0], string[1]))
lst = list(sum(not_possible, ()))
for city in range(1, cities + 1):
	if city not in lst:
		middle = city
		break
possible = []
for i in range(1, cities + 1):
	if (middle, i) not in not_possible and i != middle:
		possible.append((middle, i))
print(len(possible))
for i in range(len(possible)):
	print(possible[i][0], possible[i][1])


(n, m) = map(int, input().split())
li = [set() for i in range(n + 1)]
for i in range(m):
	(a, b) = map(int, input().split())
	li[a].add(b)
	li[b].add(a)
for i in range(1, n + 1):
	if len(li[i]) == 0:
		note = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != note:
		print(note, i)


def main():
	(n, m) = map(int, input().split())
	adj = [[0 for _ in range(n)] for _ in range(n)]
	for _ in range(m):
		(a, b) = map(int, input().split())
		adj[a - 1][b - 1] = -1
		adj[b - 1][a - 1] = -1
	index = 0
	for i in range(n):
		cnt = 0
		for j in range(n):
			if adj[i][j] == -1:
				break
			else:
				cnt += 1
		if cnt == n:
			index = i
			break
	print(n - 1)
	for i in range(n):
		if index != i:
			print(index + 1, i + 1)
	return
main()


(n, m) = [int(c) for c in input().split(' ')]
mas = [-1] + [False for c in range(0, n)]
it = 1
while it <= m:
	(z, x) = [int(c) for c in input().split(' ')]
	mas[z] = True
	mas[x] = True
	it += 1
it = 1
while it <= n:
	if mas[it] == False:
		break
	it += 1
print(n - 1)
for ab in range(1, n + 1):
	if ab != it:
		print(ab, it)


import os
import sys
from io import BytesIO, IOBase
import math as M
import itertools as ITR
from collections import defaultdict as D
from collections import Counter as C
from collections import deque as Q
import threading
from functools import lru_cache, reduce
from functools import cmp_to_key as CMP
from bisect import bisect_left as BL
from bisect import bisect_right as BR
import random as R
import string
import cmath, time
enum = enumerate
start_time = time.time()
MOD = 1000000007
MA = float('inf')
MI = float('-inf')
di8 = ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))
di4 = ((1, 0), (0, 1), (-1, 0), (0, -1))

def increase_stack():
	sys.setrecursionlimit(2 ** 32 // 2 - 1)
	threading.stack_size(1 << 27)
	t = threading.Thread(target=main)
	t.start()
	t.join()

def prints(a):
	print(a, end=' ')

def binary(n):
	return bin(n)[2:]

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def maxfactor(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
	if q:
		return q[-1]

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	l.sort()
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countchar(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def str_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def lis(arr):
	n = len(arr)
	lis = [1] * n
	maximum = 0
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
				maximum = max(maximum, lis[i])
	return maximum

def lcm(arr):
	a = arr[0]
	val = arr[0]
	for i in range(1, len(arr)):
		gcd = gcd(a, arr[i])
		a = arr[i]
		val *= arr[i]
	return val // gcd

def ncr(n, r):
	return M.factorial(n) // (M.factorial(n - r) * M.factorial(r))

def npr(n, r):
	return M.factorial(n) // M.factorial(n - r)

def inint():
	return int(inp())

def inarr():
	return list(map(int, inp().split()))

def invar():
	return map(int, inp().split())

def instr():
	s = inp()
	return list(s)

def insarr():
	return list(inp())
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
TestCases = 0

def solve():
	(n, m) = invar()
	possible = set(range(1, n + 1))
	for i in range(m):
		(x, y) = invar()
		possible.discard(x)
		possible.discard(y)
	center = possible.pop()
	print(n - 1)
	for i in range(1, n + 1):
		if i == center:
			continue
		print(center, i)

def main():
	flag = 0
	try:
		sys.stdin = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/input.txt', 'r')
		sys.stdout = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/output.txt', 'w')
	except:
		flag = 1
	t = 1
	if TestCases:
		t = inint()
	for _ in range(1, t + 1):
		solve()
	if not flag:
		print('Time: %.4f sec' % (time.time() - start_time))
		localtime = time.asctime(time.localtime(time.time()))
		print(localtime)
		sys.stdout.close()
main()


(n, m) = map(int, input().split())
bad_roads = []
for i in range(m):
	(a, b) = map(int, input().split())
	bad_roads.append(a)
	bad_roads.append(b)
root = 0
for i in range(1, n + 1):
	if not i in bad_roads:
		root = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != root:
		print(root, i)


def check(pairs, possibility):
	for p in pairs:
		if p[0] == possibility[0] or p[1] == possibility[0]:
			return False
	return True

def rec(idx, cities):
	if cities[:] == [None] * len(cities) or idx > len(cities):
		return
	for c in range(0, len(cities)):
		if cities[c] != None:
			if check(pairs, [idx, c + 1]):
				if cities[c] == idx:
					cities[c] = None
					continue
				else:
					s.append([idx, c + 1])
					cities[c] = None
			else:
				break
	if s != None:
		rec(idx + 1, cities)
	else:
		return
	return s
(cities, p) = map(int, input().split())
pairs = [None] * p
for m in range(0, p):
	pairs[m] = sorted(list(map(int, input().split())))
s = []
output = rec(1, [i for i in range(1, cities + 1)])
l = len(output)
print(l)
if l == 0:
	pass
else:
	for o in output:
		print(f'{o[0]} {o[1]}')


(n, m) = map(int, input().strip().split())
taken = set()
for i in range(m):
	(a, b) = map(int, input().strip().split())
	taken.add(a)
	taken.add(b)
print(n - 1)
for i in range(1, n + 1):
	if i not in taken:
		center = i
		break
for i in range(1, n + 1):
	if i != center:
		print(center, i)


(n, m) = map(int, input().split())
noroad = set()
for _ in range(m):
	(u, v) = map(int, input().split())
	noroad.add((u, v))

def f(n, E):
	center = None
	for v in range(1, n + 1):
		blocked = False
		for (u, w) in E:
			if u == v or w == v:
				blocked = True
		if not blocked:
			center = v
			break
	r = []
	for v in range(1, n + 1):
		if v != center:
			r.append((center, v))
	return r
ans = f(n, noroad)
print(len(ans))
for (u, v) in ans:
	print(u, v)


f = lambda : list(map(int, input().split()))
(n, m) = f()
s = set([x for x in range(1, n + 1)])
for _ in range(m):
	s.difference_update(set(f()))
center = next(iter(s))
print(n - 1)
for i in range(1, n + 1):
	if i == center:
		continue
	print(center, i)


(n, m) = map(int, input().split())
if m == 0:
	print(n - 1)
	for i in range(2, n + 1):
		print(1, i)
else:
	l = []
	d1 = {}
	d2 = {}
	for i in range(m):
		(x, y) = map(int, input().split())
		d1[x] = y
		d2[y] = x
	k = 0
	for i in range(1, n + 1):
		if i not in d1 and i not in d2:
			k = i
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i == k:
			continue
		else:
			print(k, i)


(n, m) = map(int, input().split())
s_e = set((i for i in range(n)))
for _ in range(m):
	(x, y) = map(int, input().split())
	s_e.discard(y - 1)
	s_e.discard(x - 1)
c = s_e.pop()
print(n - 1)
for i in range(n):
	if i != c:
		print(' '.join((str(x) for x in [i + 1, c + 1])))


(n, m) = [int(x) for x in input().split(' ')]
free_nodes = [True] * n
for _ in range(m):
	(source, dest) = [int(x) for x in input().split(' ')]
	(free_nodes[source - 1], free_nodes[dest - 1]) = (False, False)
first_free_node = free_nodes.index(True) + 1
print(n - 1)
other_nodes = [x for x in range(1, n + 1) if x != first_free_node]
for node in other_nodes:
	print('{0} {1}'.format(first_free_node, node))


(n, m) = [int(x) for x in input().split()]
a = []
b = [0] * n
for i in range(m):
	a.append([int(x) for x in input().split()])
	b[a[i][0] - 1] += 1
	b[a[i][1] - 1] += 1
for i in range(len(b)):
	if b[i] == 0:
		print(n - 1)
		for j in range(1, n + 1):
			if j != i + 1:
				print(i + 1, j)
		break


(n, m) = map(int, input().split())
table = [False] * (n + 1)
for _ in range(m):
	(a, b) = map(int, input().split())
	table[a] = table[b] = True
print(n - 1)
for i in range(1, n + 1):
	if not table[i]:
		for j in range(1, n + 1):
			if i != j:
				print(i, j)
		break


(n, m) = map(int, input().split())
s = {x for x in range(1, n + 1)}
for _ in range(m):
	(a, b) = map(int, input().split())
	if a in s:
		s.remove(a)
	if b in s:
		s.remove(b)
print(n - 1)
v = list(s)[0]
for u in range(1, n + 1):
	if v == u:
		continue
	print(v, u)


import itertools
import math
from collections import defaultdict

def input_ints():
	return list(map(int, input().split()))

def solve():
	(n, m) = input_ints()
	use = [0] * n
	for i in range(m):
		(x, y) = input_ints()
		use[x - 1] = 1
		use[y - 1] = 1
	x = use.index(0)
	print(n - 1)
	for i in range(n):
		if i != x:
			print(x + 1, i + 1)
solve()


(n, m) = map(int, input().split())
s = set((i for i in range(1, n + 1)))
for i in range(m):
	(u, v) = map(int, input().split())
	s.discard(u)
	s.discard(v)
s = list(s)
k = s[0]
print(n - 1)
for i in range(1, n + 1):
	if i != k:
		print(k, i)


from collections import defaultdict
(n, m) = map(int, input().split())
banned_edges = defaultdict(list)
for _ in range(m):
	road = input().split()
	(a, b) = (int(road[0]), int(road[1]))
	banned_edges[a].append(b)
	banned_edges[b].append(a)
center = min(range(1, n + 1), key=banned_edges.__getitem__)
result = []
for v in range(1, n + 1):
	if v == center:
		continue
	if center in banned_edges[v]:
		for u in range(1, n + 1):
			if u == v or u == center:
				continue
			if v not in banned_edges[u] and u not in banned_edges[center]:
				result.append('{} {}'.format(v, center))
	else:
		result.append('{} {}'.format(v, center))
print(len(result))
print('\n'.join(result))


(num, constraints) = map(int, input().split())
pairs = []
ans = 0
for x in range(constraints):
	(one, two) = map(int, input().split())
	pairs.append(one)
	pairs.append(two)
for x in range(1, num + 1):
	if x not in pairs:
		ans = x
		break
print(num - 1)
for x in range(1, num + 1):
	if x != ans:
		print(f'{x} {ans}')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, m) = LI()
	aa = [LI() for _ in range(m)]
	s = set()
	for (a, b) in aa:
		s.add(a)
		s.add(b)
	k = -1
	for i in range(1, n + 1):
		if i not in s:
			k = i
			break
	r = []
	for i in range(1, n + 1):
		if i == k:
			continue
		r.append('{} {}'.format(i, k))
	return '{}\n{}'.format(n - 1, '\n'.join(r))
print(main())


import sys
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(n, m) = sp()
dp = set()
for i in range(1, n + 1):
	dp.add(i)
for i in range(m):
	(a, b) = sp()
	dp.discard(a)
	dp.discard(b)
middle = 1
for i in dp:
	middle = i
	break
out(str(n - 1) + '\n')
for i in range(1, n + 1):
	if i == middle:
		continue
	out(str(middle) + ' ' + str(i) + '\n')
exit()


(number_1, number_2) = map(int, input().split())
vector = [0] * number_1
for index in range(number_2):
	(x, y) = map(int, input().split())
	vector[x - 1] = 1
	vector[y - 1] = 1
VERCTOR = vector.index(0) + 1
print(number_1 - 1)
for index in range(1, number_1 + 1):
	if index != VERCTOR:
		print(VERCTOR, index)


(n, m) = map(int, input().split())
bad_roads = []
for i in range(m):
	(a, b) = map(int, input().split())
	bad_roads.append(a)
	bad_roads.append(b)
tmp = [i not in bad_roads for i in range(1, n + 1)]
root = tmp.index(True) + 1
print(n - 1)
for i in range(1, n + 1):
	if i != root:
		print(root, i)


(n, m) = map(int, input().split())
visited = [False] * n
for _ in range(m):
	(a, b) = map(int, input().split())
	visited[a - 1] = True
	visited[b - 1] = True
for i in range(n):
	if visited[i] == False:
		Ans = [i + 1]
		break
List = list(set([x for x in range(1, n + 1)]) - set(Ans))
print(n - 1)
for i in List:
	print(Ans[0], i)


(n, m) = map(int, input().split())
c = []
for i in range(1, n + 1):
	c.append(i)
x = []
for i in range(m):
	(a, b) = map(int, input().split())
	x.append(a)
	x.append(b)
for i in c:
	if i not in set(x):
		break
ans = i
a = []
for i in range(len(c)):
	if c[i] != ans:
		temp = []
		temp.append(ans)
		temp.append(c[i])
		a.append(temp)
print(len(a))
for i in range(len(a)):
	print(a[i][0], a[i][1])


n = [int(x) for x in input().split()]
(nb_cities, nb_enemies_city) = (n[0], n[1])
cities = [False] * nb_cities
for i in range(nb_enemies_city):
	n = [int(x) for x in input().split()]
	(n1, n2) = (n[0], n[1])
	cities[n1 - 1] = True
	cities[n2 - 1] = True
center = 0
for i in range(len(cities)):
	if not cities[i]:
		center = i
		break
print(nb_cities - 1)
for i in range(nb_cities):
	if i != center:
		print(i + 1, center + 1)


import sys
sys.setrecursionlimit(10 ** 6)
debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == '-d' else False
if debug_mode:
	import os
	infile = open(os.path.abspath(__file__).replace('.py', '.in'))

	def input():
		return infile.readline()

def main():
	(n, m) = list(map(int, input().strip().split()))
	G = {i: [] for i in range(1, n + 1)}
	S = set()
	for _ in range(m):
		(a, b) = list(map(int, input().strip().split()))
		S.add(a)
		S.add(b)
	center = -1
	for u in G:
		if u in S:
			continue
		center = u
		break
	n_roads = n - 1
	print(n_roads)
	for u in G:
		if u != center:
			print(center, u)
main()
if debug_mode:
	infile.close()


(n, m) = map(int, input().split())
a = [0] * 1003
for i in range(m):
	(k1, k2) = map(int, input().split())
	a[k1] = 1
	a[k2] = 1
ans = 0
for i in range(1, n + 1):
	if a[i] == 0:
		ans = i
		break
print(n - 1)
for i in range(1, n + 1):
	if ans != i:
		print(ans, i)


vals = [int(x) for x in input().split()]
cities = vals[0]
numPairs = vals[1]
roadForCities = set(range(1, cities + 1))
for _ in range(numPairs):
	pair = [int(x) for x in input().split()]
	if pair[0] in roadForCities:
		roadForCities.remove(pair[0])
	if pair[1] in roadForCities:
		roadForCities.remove(pair[1])
print(cities - 1)
center = roadForCities.pop()
for city in range(1, cities + 1):
	if city != center:
		print('%d %d' % (city, center))


import sys, math, bisect
inf = float('inf')
mod = 998244353

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors
from collections import deque, defaultdict, Counter
import heapq, string

def rotate(s, x):
	s = list(s)
	if len(s) % 2 != (x + 1) % 2:
		return s[x:] + s[:x]
	else:
		return s[x:] + s[:x][::-1]
for _ in range(1):
	(n, k) = map(int, input().split())
	arr = []
	for _ in range(k):
		arr.append(list(map(int, input().split())))
	avail = [None] * n
	for i in arr:
		for j in i:
			avail[j - 1] = 1
	ind = -1
	for i in range(n):
		if avail[i] == None:
			ind = i + 1
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i != ind:
			print(ind, i)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	vis = [0] * (n + 1)
	for _ in range(m):
		(a, b) = map(int, input().split())
		vis[a] = 1
		vis[b] = 1
	z = 0
	for i in range(1, n + 1):
		if vis[i]:
			continue
		z = i
		break
	print(n - 1)
	for i in range(1, n + 1):
		if z == i:
			continue
		print(i, z)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
from collections import defaultdict as dt
from sys import stdin
inp = lambda : stdin.readline().strip()
intinp = lambda : int(inp())
mod = int(1000000000.0) + 7
inf = float('inf')
listinp = lambda : list(map(int, stdin.readline().split()))
mapinp = lambda : map(int, stdin.readline().split())
INT_MAX = 2147483647
INT_MIN = -2147483648
for _ in range(1):
	(n, m) = mapinp()
	a = [0 for i in range(n + 1)]
	for i in range(m):
		(c, b) = mapinp()
		a[c] = 1
		a[b] = 1
	j = 0
	for i in range(n + 1):
		if a[i] == 0 and i != 0:
			j = i
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i != j:
			print(i, j)


(termo1, termo2) = (int(_) for _ in input().split())
lista = [True] * termo1
for i in range(termo2):
	(x, y) = (int(_) for _ in input().split())
	lista[x - 1] = lista[y - 1] = False
aux = -1
for i in range(termo1):
	if lista[i]:
		aux = i
		break
print(termo1 - 1)
for i in range(termo1):
	if aux != i:
		print(i + 1, aux + 1)


(n, m) = map(int, input().split())
node = set([i + 1 for i in range(n)])
for _ in range(m):
	(a, b) = map(int, input().split())
	if a in node:
		node.remove(a)
	if b in node:
		node.remove(b)
print(n - 1)
center = node.pop()
for i in range(1, n + 1):
	if i == center:
		continue
	print(center, i)


L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
x = []
for i in range(m):
	(a, b) = M()
	x.append(a)
	x.append(b)
y = sorted(set(x))
j = 1
for i in range(len(y)):
	if j != y[i]:
		break
	j += 1
print(n - 1)
for i in range(1, j):
	print(i, j)
for i in range(j + 1, n + 1):
	print(i, j)


I = lambda : map(int, input().split())
(n, m) = I()
temp = set(range(1, n + 1))
for i in range(m):
	temp -= set(I())
t = temp.pop()
print(n - 1)
for i in range(1, n + 1):
	if i != t:
		print(t, i)


(x, y) = map(int, input().split())
set1 = set()
main = 0
for i in range(y):
	(a, b) = map(int, input().split())
	set1.add(a)
	set1.add(b)
for i in range(1, x + 1):
	if i not in set1:
		main = i
		break
print(x - 1)
if x == 1:
	exit()
elif x == 2:
	print(1, 2)
	exit()
for i in range(1, x + 1):
	if i != main:
		print(main, i)


import sys, math, cmath, time, collections
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import nsmallest, nlargest, heapify, heappop, heappush, heapreplace
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi
from bisect import bisect_left, bisect_right
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def input_as_array():
	return list(map(int, input().split()))
start_time = time.time()

def solve(n, m, disjoint):
	no_construct = [item for sublist in disjoint for item in sublist]
	candidate = None
	for i in range(1, n + 1):
		if i not in no_construct:
			candidate = i
			break
	no_construct = list(set(no_construct))
	rest_of_cities = [i for i in range(1, n + 1) if i not in no_construct and i != candidate]
	rest_of_cities += no_construct
	print(len(rest_of_cities))
	for i in range(len(rest_of_cities)):
		print(candidate, rest_of_cities[i])

def main():
	(n, m) = input_as_array()
	i = 0
	disjoint = []
	while i < m:
		(u, v) = input_as_array()
		disjoint.append((u, v))
		i += 1
	solve(n, m, disjoint)
LOCAL = False
if LOCAL:
	sys.stdin = open('../io/data.in', 'r')
	sys.stdout = open('../io/data.out', 'w')
testcases = 1
for i in range(testcases):
	main()
if LOCAL:
	print(f'Time Elapsed: {time.time() - start_time} seconds')
	sys.stdout.close()


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
mydict = {i: False for i in range(1, n + 1)}
for i in range(m):
	(x, y) = get_ints()
	mydict[x] = True
	mydict[y] = True
for i in mydict:
	if not mydict[i]:
		node = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != node:
		print(node, i)


(n, m) = [int(i) for i in input().split()]
numbers = []
for x0 in range(1, n + 1):
	numbers.append(x0)
for a0 in range(m):
	(a, b) = [int(i) for i in input().split()]
	if a in numbers:
		numbers.remove(a)
	if b in numbers:
		numbers.remove(b)
if len(numbers) > 0:
	print(n - 1)
	for x in range(1, n + 1):
		if x != numbers[0]:
			print(str(numbers[0]) + ' ' + str(x))
else:
	print(0)


(n, m) = map(int, input().split())
ss = set()
for i in range(m):
	(u, v) = map(int, input().split())
	ss.add(u)
	ss.add(v)
for i in range(1, n + 1):
	m = i if i not in ss else m
print(n - 1)
for i in range(1, n + 1):
	if i != m:
		print(i, m)


(n, m) = map(int, input().split())
a = []
for i in range(m):
	(x, y) = map(int, input().split())
	a.append(x)
	a.append(y)
a = set(a)
z = []
for i in range(n):
	z.append(i + 1)
v = list(set(z) - a)
a = list(a)
print(n - 1)
for i in range(n):
	if z[i] != v[0]:
		print(v[0], z[i])


f = lambda : map(int, input().split(' '))
(n, m) = f()
print(n - 1)
if m == 0:
	for j in range(2, n + 1):
		print(1, ' ', j)
else:
	s = set()
	for j in range(m):
		s = set(f()).union(s)
	ss = set([i for i in range(1, n + 1)]).difference(s)
	kp = list(ss)[0]
	for j in range(1, n + 1):
		if j != kp:
			print(j, ' ', kp)


(n, m) = map(int, input().split())
full = []
full2 = list(range(1, n + 1))
i = 0
b = 0
while i < m:
	(x, y) = map(int, input().split())
	full.append(x)
	full.append(y)
	i += 1
for i in range(1, n + 1):
	if i not in full:
		b = i
		full2.remove(b)
		print(n - 1)
		for i in full2:
			print(str(b) + ' ' + str(i))
		break


(n, m) = map(int, input().split())
visited = [True for _ in range(n + 1)]
for i in range(m):
	(a, b) = map(int, input().split())
	visited[a] = False
	visited[b] = False
for i in range(1, n + 1):
	if visited[i] == True:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != center:
		print(i, center)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for i in range(1):
	(n, k) = lst()
	s = {i for i in range(1, n + 1)}
	for i in range(k):
		(a, b) = lst()
		if a in s:
			s.remove(a)
		if b in s:
			s.remove(b)
	mid = list(s)[0]
	print(n - 1)
	for i in range(1, n + 1):
		if i != mid:
			print(mid, i)


(n, m) = map(int, input().split())
vis = []
for i in range(n):
	vis.append(0)
for i in range(m):
	(a, b) = map(int, input().split())
	vis[a - 1] = 1
	vis[b - 1] = 1
center = -1
for i in range(n):
	if vis[i] == 0:
		center = i
		break
print(n - 1)
for i in range(n):
	if i == center:
		continue
	print(i + 1, center + 1)


(n, m) = [int(x) for x in input().strip().split(' ')]
unsafe = {}
for i in range(m):
	(p, q) = [int(x) for x in input().strip().split(' ')]
	if not unsafe.get(p):
		unsafe[p] = 0
	unsafe[p] += 1
	if not unsafe.get(q):
		unsafe[q] = 0
	unsafe[q] += 1
centre_point = 1
for i in range(1, n + 1):
	if not unsafe.get(i):
		centre_point = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != centre_point:
		print(i, centre_point)


(n, m) = map(int, input().split())
if n == 1 and m == 0:
	print(0)
elif m == 0:
	print(n - 1)
	print(1, 2)
	for i in range(3, n + 1):
		print(2, i)
else:
	l = []
	for i in range(m):
		(a, b) = map(int, input().split())
		l.extend([a, b])
	for i in range(2, n + 1):
		if i not in l:
			temp = i
			break
	c = 1
	for i in range(2, n + 1):
		if i != temp:
			c = c + 1
	print(c)
	print(1, temp)
	for i in range(2, n + 1):
		if i != temp:
			print(temp, i)


(n, m) = map(int, input().split())
roads = [False] * (n + 1)
for i in range(m):
	(a, b) = map(int, input().split())
	roads[a] = True
	roads[b] = True
center = 0
for i in range(1, n + 1):
	if roads[i] == False:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != center:
		print('%d %d' % (center, i))


(n, m) = map(int, input().split())
a = {}
for _ in range(m):
	(b, c) = map(int, input().split())
	if b in a:
		a[b] += 1
	else:
		a[b] = 1
	if c in a:
		a[c] += 1
	else:
		a[c] = 1
var = 0
for i in range(1, n + 1):
	if i not in a:
		var = i
print(n - 1)
for i in range(1, n + 1):
	if i != var:
		print(var, i)


(n, m) = input().split()
n = int(n)
m = int(m)
ban = [True] * (n + 1)
ban[0] = False
for i in range(m):
	L = input().split()
	L[0] = int(L[0])
	L[1] = int(L[1])
	ban[L[0]] = False
	ban[L[1]] = False
x = ban.index(True)
print(n - 1)
for i in range(1, n + 1):
	if i == x:
		continue
	print(i, end=' ' + str(x) + '\n')


arr = [int(x) for x in input().split()]
(n, m) = (arr[0], arr[1])
s = set()
ans = []
for i in range(m):
	li = [int(x) for x in input().split()]
	s.add(li[0])
	s.add(li[1])
for i in range(n):
	if i + 1 not in s:
		for j in range(n):
			if i != j:
				ans.append([i + 1, j + 1])
		break
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


import sys
input = lambda : sys.stdin.readline().rstrip()
(n, m) = [int(i) for i in input().split()]
st = set()
for i in range(m):
	(x, y) = [int(i) - 1 for i in input().split()]
	st.add(x)
	st.add(y)
donkey = -1
for i in range(n):
	if i not in st:
		donkey = i
print(n - 1)
for i in range(n):
	if i == donkey:
		continue
	else:
		print(i + 1, donkey + 1)


(n, m) = map(int, input().split())
visited = []
for i in range(m):
	(inp1, inp2) = map(int, input().split())
	visited.append(inp1)
	visited.append(inp2)
a = 0
for i in range(1, n + 1):
	if i not in visited:
		a = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != a:
		print(i, a)


(n, m) = map(int, input().split())
d1 = {}
d2 = {}
if m == 0:
	print(n - 1)
	for i in range(2, n + 1):
		print(1, i)
else:
	for i in range(m):
		(u, v) = map(int, input().split())
		d1[u] = v
		d2[v] = u
	print(n - 1)
	k = 0
	for j in range(1, n + 1):
		if j not in d1 and j not in d2:
			k = j
			break
	for j in range(1, n + 1):
		if j == k:
			continue
		else:
			print(k, j)


(n, m) = map(int, input().split())
not_connected = []
for _ in range(m):
	(a, b) = map(int, input().split())
	not_connected.append(a)
	not_connected.append(b)
for i in range(1, n + 1):
	if i not in not_connected:
		ans = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i == ans:
		continue
	print(i, ans)


import sys
from collections import defaultdict
MOD = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def print_array(a):
	print(' '.join(map(str, a)))

def main():
	(n, m) = get_ints()
	canBuild = [[True for _ in range(n + 1)] for _ in range(n + 1)]
	for _ in range(m):
		(x, y) = get_ints()
		canBuild[x][y] = canBuild[y][x] = False
	c = 0
	for i in range(1, n + 1):
		flag = True
		for j in range(1, n + 1):
			if not canBuild[i][j]:
				flag = False
				break
		if flag:
			c = i
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i == c:
			continue
		print(i, c)
main()


(n, m) = map(int, input().split())
arr = [False] * 1001
for _ in range(m):
	(u, v) = map(int, input().split())
	arr[u] = True
	arr[v] = True
print(n - 1)
x = 1
while arr[x]:
	x += 1
for i in range(1, x):
	print(i, x)
for j in range(x + 1, n + 1):
	print(x, j)


(nodes, edges) = [int(x) for x in input().split()]
roads = {}
for n in range(1, nodes + 1):
	roads[n] = []
for e in range(edges):
	(n, m) = [int(x) for x in input().split()]
	roads[n].append(m)
	roads[m].append(n)
mid = 0
for (x, neighs) in roads.items():
	if len(neighs) == 0:
		mid = x
		break
print(nodes - 1)
for n in range(1, nodes + 1):
	if n != mid:
		print(mid, n)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
(n, m) = L()
A = [L() for i in range(m)]
count = [0 for i in range(n + 1)]
for ele in A:
	count[ele[0]] += 1
	count[ele[1]] += 1
for i in range(1, n + 1):
	if count[i] == 0:
		break
print(n - 1)
for j in range(1, n + 1):
	if j != i:
		print(i, j)
endtime = time.time()


(n, m) = map(int, input().split())
a = [0] * (n + 1)
i = 0
while i < m:
	(j, k) = map(int, input().split())
	a[j] = 1
	a[k] = 1
	i += 1
i = 1
while i <= n:
	if a[i] == 0:
		break
	i += 1
j = 1
print(n - 1)
while j <= n:
	if j != i:
		print(j, i)
	j += 1


(n, m) = map(int, input().split())
roads = n - 1
invalid_centers = set()
center = 1
for i in range(m):
	(u, v) = map(int, input().split())
	invalid_centers.add(u)
	invalid_centers.add(v)
for i in range(1, n + 1):
	if i not in invalid_centers:
		center = i
		break
print(roads)
for i in range(1, n + 1):
	if i != center:
		print(center, i)


(n, m) = [int(x) for x in input().split()]
arr = [0 for i in range(n)]
for i in range(m):
	(a, b) = [int(x) for x in input().split()]
	arr[a - 1] = 1
	arr[b - 1] = 1
for i in range(n):
	if arr[i] == 0:
		ind = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != ind + 1:
		print(ind + 1, i)


import math
import sys
from collections import defaultdict
from collections import Counter
from collections import deque
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, m) = ilele()
mark = {}
for i in range(m):
	(a, b) = ilele()
	mark[a] = 1
	mark[b] = 1
x = 0
for i in range(1, n + 1):
	if mark.get(i, -1) == -1:
		x = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != x:
		print(i, x)


(n, m) = map(int, input().split())
if m == 0:
	print(n - 1)
	for i in range(1, n):
		print(n, i)
else:
	cond = []
	for i in range(m):
		(ai, bi) = map(int, input().split())
		cond.append(ai)
		cond.append(bi)
	for j in range(1, n + 1):
		if j not in set(cond):
			break
	a = j
	print(n - 1)
	for j in range(1, n + 1):
		if j != a:
			print(a, j)


(n, m) = map(int, input().split())
a = [0] * (n + 1)
while m:
	(x, y) = map(int, input().split())
	a[x] += 1
	a[y] += 1
	m -= 1
j = -1
for q in range(1, n + 1):
	if a[q] == 0:
		j = q
		break
print(n - 1)
for q in range(1, n + 1):
	if q == j:
		continue
	print(j, q)


(n, m) = map(int, input().split())
d = {}
for _ in range(m):
	(a, b) = map(int, input().split())
	d[a] = 1
	d[b] = 1
find = 1
while find in d:
	find += 1
print(n - 1)
l = list(range(1, n + 1))
for x in l:
	if x != find:
		print(str(find) + ' ' + str(x))


(n, m) = map(int, input().split())
d = {}
for it in range(m):
	(x, y) = map(int, input().split())
	d[x] = 1
	d[y] = 1
p = -1
for i in range(1, n + 1):
	if i not in d:
		p = i
		break
print(n - 1)
k = 1
if k == p:
	k += 1
for t in range(n - 1):
	print(k, p)
	k += 1
	if k == p:
		k += 1


class Graph:

	def __init__(self, n, m, roadsNotAllowed):
		self.n = n
		self.m = m
		self.roadsNotAllowed = roadsNotAllowed
		self._canBeRoot = set((x + 1 for x in range(n)))
		self._graph = []

	def _removeEdges(self):
		for i in range(len(self.roadsNotAllowed)):
			(a, b) = self.roadsNotAllowed[i]
			if a in self._canBeRoot:
				self._canBeRoot.remove(a)
			if b in self._canBeRoot:
				self._canBeRoot.remove(b)

	def _makeGraph(self):
		root = next(iter(self._canBeRoot))
		self._graph = [(root, x) for x in range(1, self.n + 1) if x != root]

	def print(self):
		for i in range(len(self._graph)):
			print(self._graph[i][0], self._graph[i][1])

	def printSol(self):
		self._removeEdges()
		self._makeGraph()
		print(self.n - 1)
		self.print()

class Solution:

	def solve(self):
		(n, m) = input().strip().split()
		(n, m) = (int(n), int(m))
		arr = []
		for i in range(m):
			(a, b) = input().split()
			(a, b) = (int(a), int(b))
			arr.append((a, b))
		Graph(n, m, arr).printSol()
Solution().solve()


def main():
	(n, m) = map(int, input().split())
	cand = set(range(1, n + 1))
	for _ in range(m):
		(a, b) = map(int, input().split())
		cand.discard(a)
		cand.discard(b)
	choice = next(iter(cand))
	res = []
	for i in range(1, n + 1):
		if i != choice:
			res.append('{} {}'.format(i, choice))
	print(len(res))
	print('\n'.join(res))
main()


def mi():
	return map(int, input().split())
(n, m) = mi()
av = [0] * n
for _ in range(m):
	(a, b) = mi()
	a -= 1
	b -= 1
	av[a] += 1
	av[b] += 1
if 0 in av:
	i = av.index(0) + 1
	print(n - 1)
	for _ in range(n):
		_ += 1
		if _ != i:
			print(i, _)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
(n, m) = map(int, input().split())
d = {i: set() for i in range(1, n + 1)}
for _ in range(m):
	(u, v) = map(int, input().split())
	d[u].add(v)
	d[v].add(u)
if n == 1:
	print(0)
	sys.exit(0)
a = sorted(d.items(), key=lambda x: len(x[1]))
(x, y) = (a[0][0], a[1][0])
used = set()
ans = []
for i in range(1, n + 1):
	if i == x:
		continue
	if i not in d[x] and i not in used:
		ans.append([x, i])
		used.add(i)
for i in range(1, n + 1):
	if i == x:
		continue
	if i not in d[y] and i not in used:
		used.add(i)
		ans.append([y, i])
print(len(ans))
for i in ans:
	print(*i)


from collections import defaultdict
graph = defaultdict(list)
(n, m) = map(int, input().split())
center = [True] * (n + 1)
center[0] = False
for _ in range(m):
	(a, b) = map(int, input().split())
	center[a] = False
	center[b] = False
c = 1
for i in range(n + 1):
	if center[i]:
		c = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != c:
		print(c, i)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum
import sys
import threading
from math import *
sys.setrecursionlimit(300000)
threading.stack_size(10 ** 8)
for _ in range(1):
	(n, m) = map(int, input().split())
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	center = -1
	for (k, v) in adj.items():
		if v == 0:
			center = k
			break
	print(n - 1)
	for i in range(1, n + 1):
		if i != center:
			print(center, i)


from sys import stdin, stdout
(n, m) = list(map(lambda i: int(i), stdin.readline().rstrip().split()))
flag = [False] * 1005
for i in range(m):
	(a, b) = list(map(lambda i: int(i), stdin.readline().rstrip().split()))
	flag[a] = True
	flag[b] = True
index = 1
while flag[index]:
	index += 1
stdout.write(str(n - 1) + '\n')
for i in range(1, index):
	stdout.write(str(i) + ' ' + str(index) + '\n')
for i in range(index + 1, n + 1):
	stdout.write(str(index) + ' ' + str(i) + '\n')


import sys
from collections import Counter
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
(N, M) = invr()
s = set()
for m in range(M):
	(x, y) = invr()
	s.add(x)
	s.add(y)
source = -1
for n in range(1, N + 1):
	if n not in s:
		source = n
		break
print(N - 1)
for i in range(1, N + 1):
	if i != source:
		print(source, i)


(n, k) = map(int, input().split())
a = [1] * (n + 1)
for i in range(k):
	(x, y) = map(int, input().split())
	a[x] = 0
	a[y] = 0
for i in range(1, len(a)):
	if a[i] != 0:
		p = i
		break
j = 1
print(n - 1)
for i in range(n):
	if j != p:
		print(p, j)
	j += 1


(n, m) = map(int, input().split())
nr = set()
for _ in range(m):
	(a, b) = map(int, input().split())
	nr.add(a)
	nr.add(b)
cities = {i for i in range(1, n + 1)}
rem = cities - nr
print(n - 1)
mid = rem.pop()
for i in range(1, n + 1):
	if i != mid:
		print(i, mid)


(n, r) = list(map(int, input().split()))
rest = [False] * 1001
for i in range(r):
	(u, v) = list(map(int, input().split()))
	rest[u] = True
	rest[v] = True
x = 1
while rest[x]:
	x += 1
print('%d' % (n - 1))
for i in range(1, x):
	print('%d %d' % (i, x))
for i in range(x + 1, n + 1):
	print('%d %d' % (x, i))


from collections import defaultdict
(n, m) = map(int, input().split())
graph = defaultdict(list)
for i in range(m):
	(c1, c2) = map(int, input().split())
	graph[c1].append(c2)
	graph[c2].append(c1)
center = None
for i in range(1, n + 1):
	if not i in graph:
		center = i
		break
print(n - 1)
for i in range(1, n + 1):
	if i != center:
		print(center, i)


(n, m) = map(int, input().split())
city = [i for i in range(1, n + 1)]
nodes = []
center = city[0]
if m != 0:
	for i in range(m):
		(x, y) = map(int, input().split())
		nodes += [x, y]
	for i in city:
		if i not in nodes:
			center = i
			break
city.remove(center)
print(len(city))
for i in range(len(city)):
	print(city[i], str(center))


(n, m) = list(map(int, input().split()))
can = [True] * (n + 1)
for i in range(m):
	(a, b) = list(map(int, input().split()))
	can[a] = can[b] = False
for i in range(1, len(can)):
	if can[i]:
		p = []
		for j in range(1, n + 1):
			if i != j:
				p.append((j, i))
		print(len(p))
		for i in p:
			print(i[0], i[1])
		exit(0)