The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n - 1) / 2 games were played during the tournament, and each participant had a match with each other participant. 

The rules of the game are quite simple — the participant who falls asleep first wins. The secretary made a record of each game in the form «xi yi», where xi and yi are the numbers of participants. The first number in each pair is a winner (i.e. xi is a winner and yi is a loser). There is no draws.

Recently researches form the «Institute Of Sleep» have found that every person is characterized by a value pj — the speed of falling asleep. The person who has lower speed wins. Every person has its own value pj, constant during the life. 

It is known that all participants of the tournament have distinct speeds of falling asleep. Also it was found that the secretary made records about all the games except one. You are to find the result of the missing game.

Input

The first line contains one integer n (3 ≤ n ≤ 50) — the number of participants. The following n·(n - 1) / 2 - 1 lines contain the results of the games. Each game is described in a single line by two integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi и yi are the numbers of the opponents in this game. It is known that during the tournament each of the n participants played n - 1 games, one game with each other participant.

Output

Output two integers x and y — the missing record. If there are several solutions, output any of them.

Examples

Input

4
4 2
4 1
2 3
2 1
3 1


Output

4 3

Difficulty: EASY
Tags: Complete search

Bit manipulation

Graph traversal

Greedy algorithms
Skill types: Complete search

Bit manipulation

Greedy algorithms

Starter code:

Solutions:
a = int(input())
d = {}
f = {}
for i in range(a * (a - 1) // 2 - 1):
	(v, c) = map(int, input().split())
	if v not in f:
		f[v] = []
	f[v].append(c)
	if v in d:
		d[v] += 1
	else:
		d[v] = 1
	if c in d:
		d[c] += 1
	else:
		d[c] = 1
s = []
m = 0
for i in range(1, a + 1):
	if d[i] > m:
		m = d[i]
for i in range(1, a + 1):
	if d[i] < m:
		s.append(i)
m = 0
for i in range(1, a + 1):
	if i not in s:
		if s[0] in f and i in f and (s[1] in f):
			if i in f[s[1]] and s[0] in f[i]:
				m = 1
				s.reverse()
				break
print(*s)


class Node:

	def __init__(self, i):
		self.index = i
		self.gamesplayed = 0
		self.p = 0

	def __repr__(self):
		return 'index: {} --gamesplayed: {} --p: {} \n'.format(self.index, self.gamesplayed, self.p)

	def __str__(self):
		return __repr__(self)
n = int(input())
players = [Node(i + 1) for i in range(n)]
games = n * (n - 1) // 2
for i in range(games - 1):
	(x, y) = map(lambda t: int(t), input().split())
	players[x - 1].gamesplayed += 1
	players[y - 1].gamesplayed += 1
	players[x - 1].p -= 1
	players[y - 1].p += 1
players.sort(key=lambda t: t.p)
(x, y) = [p.index for p in players if p.gamesplayed < n - 1]
print(x, y)


from collections import defaultdict
n = int(input())
wins = defaultdict(int)
total = defaultdict(int)
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = [int(x) for x in str(input()).split()]
	wins[x] += 1
	total[y] += 1
	total[x] += 1
for (k, v) in total.items():
	if v < n - 1:
		a = k
		total[a] += 1
		break
for (k, v) in total.items():
	if v < n - 1:
		b = k
		total[b] += 1
if wins[a] > wins[b]:
	print(a, b)
else:
	print(b, a)


from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
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()
setrecursionlimit(100000)
mod = 1000000007
n = ii1()
poss = set()
for i in range(1, n + 1):
	for j in range(i + 1, n + 1):
		poss.add((i, j))
count = n * (n - 1) // 2 - 1
win = {}
lose = {}
for i in range(count):
	(a, b) = iia()
	poss.remove(tuple(sorted([a, b])))
	win.setdefault(a, []).append(b)
	lose.setdefault(b, []).append(a)
(a, b) = poss.pop()
if len(set(win.get(a, [])) & set(lose.get(b, []))):
	print(a, b)
else:
	print(b, a)


n = int(input())
wins = [set() for _ in range(n)]
looses = [set() for _ in range(n)]
for _ in range(n * (n - 1) // 2 - 1):
	(u, v) = list(map(int, input().split()))
	u -= 1
	v -= 1
	wins[u].add(v)
	looses[v].add(u)
win_set = {}
loose_set = {}
winners = []
loosers = []
for i in range(n):
	if len(wins[i]) in win_set:
		winners.append(i)
		winners.append(win_set[len(wins[i])])
	else:
		win_set[len(wins[i])] = i
	if len(looses[i]) in loose_set:
		loosers.append(i)
		loosers.append(loose_set[len(looses[i])])
	else:
		loose_set[len(looses[i])] = i
if loosers[0] not in wins[winners[0]] and loosers[0] != winners[0]:
	print(winners[0] + 1, loosers[0] + 1)
elif loosers[0] not in wins[winners[1]] and loosers[0] != winners[1]:
	print(winners[1] + 1, loosers[0] + 1)
elif loosers[1] not in wins[winners[1]] and loosers[1] != winners[1]:
	print(winners[1] + 1, loosers[1] + 1)
else:
	print(winners[0] + 1, loosers[1] + 1)


n = int(input())
rec = []
nn = int(n * (n - 1) / 2 - 1)
for i in range(nn):
	x = input().split()
	y = 0
	while y < len(x):
		x[y] = int(x[y])
		y += 1
	rec += x
x = 0
p = [0 * i for i in range(n)]
for i in rec:
	if x % 2 == 0:
		p[i - 1] += 1
	else:
		p[i - 1] -= 1
	x += 1
y = []
x = []
for i in range(n):
	if rec.count(i + 1) == n - 2:
		x.append(i + 1)
		y.append(p[i])
		if len(y) == 2:
			break
if y[0] >= y[1]:
	print(x[0], x[1])
else:
	print(x[1], x[0])


n = int(input())
indeg = [0 for i in range(n + 1)]
outdg = [0 for i in range(n + 1)]
t = n * (n - 1) // 2 - 1
for _ in range(t):
	(a, b) = map(int, input().split())
	indeg[a] += 1
	indeg[b] += 1
	outdg[a] += 1
(x, y) = (-1, -1)
for i in range(n):
	if indeg[i + 1] != n - 1:
		if x == -1:
			x = i + 1
		else:
			y = i + 1
if outdg[x] >= outdg[y]:
	print(x, y)
else:
	print(y, x)


n = int(input())
co = {i: 0 for i in range(1, n + 1)}
wins = {i: [] for i in range(1, n + 1)}
n_ = n * (n - 1) // 2
for i in range(n_ - 1):
	(a, b) = map(int, input().split())
	co[a] += 1
	co[b] += 1
	wins[a].append(b)
m = min(co.values())
outs = list()
for el in co.keys():
	if co[el] == m:
		outs.append(el)
(a, b) = outs
for c in range(1, n + 1):
	if c in wins[a] and b in wins[c]:
		print(a, b)
		exit()
	elif c in wins[b] and a in wins[c]:
		print(b, a)
		exit()
print(a, b)


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 collections import Counter
import heapq
from collections import Counter
n = int(input())
rank = [0] * n
vis = [[0 for i in range(n)] for j in range(n)]
for i in range(n * (n - 1) // 2 - 1):
	(u, v) = map(int, input().split())
	rank[u - 1] += 1
	vis[u - 1][v - 1] = 1
	vis[v - 1][u - 1] = 1
for i in range(n):
	for j in range(n):
		if vis[i][j] == 0 and i != j:
			ans = (i + 1, j + 1)
			break
if rank[ans[0] - 1] > rank[ans[1] - 1]:
	print(ans[0], ans[1])
else:
	print(ans[1], ans[0])


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log, pi, sin
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
mod = 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)]

def dfs(source):
	path.add(source)
	vis[source] = 1
	for child in graph[source]:
		if not vis[child]:
			dfs(child)
dp = dd(int)
n = int(data())
n = n * (n - 1) // 2
graph = dd(set)
for i in range(n - 1):
	(a, b) = sp()
	graph[a].add(b)
	dp[a] += 1
	dp[b] += 1
m = max(dp.values())
answer = []
for i in dp.keys():
	if dp[i] != m:
		answer.append(i)
	if len(answer) == 2:
		break
path = set()
vis = dd(int)
dfs(answer[0])
if answer[1] in path:
	out(*answer)
	exit()
out(*answer[::-1])


def missingRecord(nParticipants, currRecord):
	storage = {str(participant): [0, set()] for participant in range(1, nParticipants + 1)}
	for record in currRecord:
		storage[record[0]][0] += 1
		storage[record[0]][1].add(record[1])
	sortedParticipants = sorted(storage.keys(), key=lambda x: storage[x][0], reverse=True)
	for i in range(nParticipants):
		if storage[sortedParticipants[i]][0] == storage[sortedParticipants[i + 1]][0]:
			if sortedParticipants[i] in storage[sortedParticipants[i + 1]][1]:
				storage[sortedParticipants[i + 1]][1].remove(sortedParticipants[i])
				(missingLoser,) = storage[sortedParticipants[i]][1].difference(storage[sortedParticipants[i + 1]][1])
				return f'{sortedParticipants[i + 1]} {missingLoser}'
			elif sortedParticipants[i + 1] in storage[sortedParticipants[i]][1]:
				storage[sortedParticipants[i]][1].remove(sortedParticipants[i + 1])
				(missingLoser,) = storage[sortedParticipants[i + 1]][1].difference(storage[sortedParticipants[i]][1])
				return f'{sortedParticipants[i]} {missingLoser}'
			return f'{sortedParticipants[i]} {sortedParticipants[i + 1]}'

def main():
	nParticipants = int(input())
	print(missingRecord(nParticipants, (input().split() for x in range(nParticipants * (nParticipants - 1) // 2 - 1))))
main()


def bfs(d, n, u, v):
	visited = [False] * n
	queue = []
	queue.append(u)
	while queue:
		s = queue.pop(0)
		if s == v:
			return True
		visited[s] = True
		for i in d[s]:
			if visited[i] == False:
				queue.append(i)
	return False
n = int(input())
d = {}
for i in range(n):
	d[i] = []
deg = [0] * n
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	deg[x - 1] += 1
	deg[y - 1] += 1
	d[x - 1].append(y - 1)
a = []
for i in range(len(deg)):
	if deg[i] == n - 2:
		a.append(i)
x = bfs(d, n, a[0], a[1])
if x:
	print(a[0] + 1, a[1] + 1)
else:
	print(a[1] + 1, a[0] + 1)


from collections import defaultdict as D
n = int(input())
t = n * (n - 1) // 2
d = D(int)
xy = []
for i in range(t - 1):
	(x, y) = map(int, input().split())
	d[x] += 1
	d[y] += 1
	xy.append((x, y))
res = []
for i in d.keys():
	if d[i] != n - 1:
		res.append(i)
ScoreA = ScoreB = 0
for (i, j) in xy:
	if res[0] == i:
		ScoreA += 3
	if res[1] == i:
		ScoreB += 3
if ScoreA >= ScoreB:
	print(res[0], res[1])
else:
	print(res[1], res[0])


import sys
from array import array

def input():
	return sys.stdin.buffer.readline().decode('utf-8')
n = int(input())
cnt = [0] * n
indeg = [0] * n
adj = [[] for _ in range(n)]
m = n * (n - 1) // 2 - 1
for (u, v) in (map(int, input().split()) for _ in range(m)):
	adj[v - 1].append(u - 1)
	cnt[u - 1] += 1
	cnt[v - 1] += 1
	indeg[u - 1] += 1
x = []
for i in range(n):
	if cnt[i] == n - 2:
		x.append(i)

def solve(win, lose):
	adj[lose].append(win)
	deg = indeg[:]
	deg[win] += 1
	stack = [i for i in range(n) if deg[i] == 0]
	while stack:
		v = stack.pop()
		for dest in adj[v]:
			if deg[dest] == 0:
				continue
			deg[dest] -= 1
			if deg[dest] == 0:
				stack.append(dest)
	adj[lose].remove(win)
	return not any(deg)
if solve(x[0], x[1]):
	print(x[0] + 1, x[1] + 1)
else:
	print(x[1] + 1, x[0] + 1)


import sys

def make_larger(cur, value=0):
	if value < max(values[cur], value):
		return
	value = max(values[cur], value)
	values[cur] = value
	if cur not in set_larger:
		return
	for new in set_larger[cur]:
		make_larger(new, value + 1)
n_games = int(sys.stdin.readline())
games = set()
ps = []
set_larger = {}
values = {}
for i in range(int(n_games * (n_games - 1) // 2 - 1)):
	(a, b) = tuple([int(x) for x in sys.stdin.readline().split()])
	ps.append((a, b))
	ps.append((b, a))
	games.add(a)
	games.add(b)
	if b not in set_larger:
		set_larger[b] = []
	set_larger[b].append(a)
for game in games:
	values[game] = 0
for game in games:
	make_larger(game)
for i in range(1, n_games + 1):
	for j in range(1, n_games + 1):
		if i != j:
			if (i, j) not in ps:
				if values[i] > values[j]:
					print(i, j)
				else:
					print(j, i)
				sys.exit(0)


x = int(input())
lis = [0] * x
lisa = [0] * x
y = x * (x - 1) // 2 - 1
for i in range(y):
	(j, k) = map(int, input().split())
	lis[j - 1] += 1
	lisa[j - 1] += 1
	lisa[k - 1] += 1
k = min(lisa)
l = lisa.index(k)
lisa.remove(k)
k = lisa.index(k) + 1
if lis[k] > lis[l]:
	print(k + 1, l + 1)
else:
	print(l + 1, k + 1)


(dic, string) = ({}, '')
n = int(input())
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	if x not in dic:
		dic[x] = {'apps': 1, 'w': [y], 'l': []}
	else:
		dic[x]['apps'] += 1
		dic[x]['w'].append(y)
	if y not in dic:
		dic[y] = {'apps': 1, 'w': [], 'l': [x]}
	else:
		dic[y]['apps'] += 1
		dic[y]['l'].append(x)
for j in range(1, n + 1):
	if dic[j]['apps'] == n - 1:
		del dic[j]
(uno, dos) = (list(dic.keys())[0], list(dic.keys())[1])
if len(list(set(dic[uno]['w']).intersection(dic[dos]['l']))) > 0:
	print(str(uno) + ' ' + str(dos))
else:
	print(str(dos) + ' ' + str(uno))


n = int(input())
a = [0] * (n + 1)
b = [[] for i in range(n + 1)]
h = [[] for i in range(n + 1)]
for i in range(n * (n - 1) // 2 - 1):
	(c, d) = map(int, input().split())
	b[c].append(d)
	a[c] += 1
	a[d] += 1
	h[d].append(c)
f = a.index(n - 2)
s = a.index(n - 2, f + 1)
co = 0
for i in h[s]:
	if i in b[f]:
		co = 1
		break
if co == 1:
	print(f, s)
else:
	print(s, f)


n = int(input())
win = list()
lose = list()
final = list()
for _ in range(int(n * (n - 1) / 2) - 1):
	(w, l) = map(int, input().split())
	win.append(w)
	lose.append(l)
for i in range(1, n + 1):
	if win.count(i) + lose.count(i) < n - 1:
		final.append(i)
if win.count(final[0]) >= win.count(final[1]):
	print(final[0], final[1])
if win.count(final[0]) < win.count(final[1]):
	print(final[1], final[0])


class graph:

	def __init__(obj):
		obj.nei = []

	def add(obj, u):
		obj.nei.append(u)

	def display(obj):
		print(obj.nei)
n = int(input())
adj = []
a = [0] * n
for i in range(n):
	adj.append(graph())
for i in range(1, n * (n - 1) // 2):
	(u, v) = map(int, input().split(' '))
	a[u - 1] += 1
	a[v - 1] += 1
	adj[u - 1].add(v)
c = []
for i in range(n):
	if a[i] != n - 1:
		c.append(i + 1)
parent = {c[0]: None}

def dfs_t(u, z):
	for v in adj[u - 1].nei:
		if v not in parent:
			parent[v] = u
			dfs_t(v, z)
dfs_t(c[0], c[1])
if c[1] in parent:
	print(str(c[0]) + ' ' + str(c[1]))
else:
	print(str(c[1]) + ' ' + str(c[0]))


n = int(input())
win = {}
neighbours = {}
for i in range(n):
	neighbours[i + 1] = []
	win[i + 1] = []
for i in range(int(n * (n - 1) / 2 - 1)):
	(x, y) = map(int, input().split())
	win[x].append(y)
	neighbours[x].append(y)
	neighbours[y].append(x)
_min = [10 ** 9, []]
for key in neighbours:
	if len(neighbours[key]) < _min[0]:
		_min = [len(neighbours[key]), [key]]
	elif len(neighbours[key]) == _min[0]:
		_min[1].append(key)
if len(win[_min[1][0]]) >= len(win[_min[1][1]]):
	print(_min[1][0], _min[1][1])
else:
	print(_min[1][1], _min[1][0])


n = int(input())
list1 = [[] for i in range(n + 1)]
list2 = []
for i in range(n * (n - 1) // 2 - 1):
	(a, b) = map(int, input().split())
	list2.append((a, b))
	list1[a].append(b)
	list1[b].append(a)
ll = []
for i in range(1, len(list1)):
	if len(list1[i]) != n - 1:
		ll.append(i)
x = ll[0]
y = ll[1]
l1 = set()
l2 = set()
l3 = set()
l4 = set()
for i in range(len(list2)):
	a = list2[i][0]
	b = list2[i][1]
	if a == x:
		l1.add(b)
	elif a == y:
		l2.add(b)
	elif b == x:
		l3.add(a)
	elif b == y:
		l4.add(a)
if len(l1.intersection(l4)) > 0:
	print(x, y)
else:
	print(y, x)


from sys import stdin
input = stdin.readline
n = int(input())
g = [n - 1] * n
a = [[int(x) for x in input().split()] for _ in range(n * (n - 1) // 2 - 1)]
for i in a:
	for j in i:
		g[j - 1] -= 1
p = []
for i in range(n):
	if g[i] > 0:
		p.append(i + 1)
(x, y) = p
r = 0
s = 0
for (i, _) in a:
	r += i == x
	s += i == y
if r >= s:
	print(x, y)
else:
	print(y, x)


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	d = dict()
	dp = dict()
	for i in range(1, n + 1):
		d[i] = 0
		dp[i] = []
	for i in range(1, n * (n - 1) // 2):
		(a, b) = map(int, input().split())
		d[a] += 1
		d[b] += 1
		dp[a].append(b)
	(x, y) = (-1, -1)
	for i in d:
		if d[i] == n - 1:
			continue
		if x == -1:
			x = i
		else:
			y = i
			break
	stack = [x]
	visited = [0] * (n + 1)
	while stack:
		z = stack.pop()
		if visited[z]:
			continue
		visited[z] = 1
		if z == y:
			print(x, y)
			exit()
		for item in dp[z]:
			stack.append(item)
	print(y, x)
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 = int(input())
games_played = [0 for i in range(n + 1)]
results = []
for i in range(n * (n - 1) // 2 - 1):
	(winner, loser) = map(int, input().split())
	results.append((winner, loser))
	games_played[winner] += 1
	games_played[loser] += 1
player_a = games_played.index(n - 2, 1)
player_b = games_played.index(n - 2, player_a + 1)
worse_than_a = set((b for (a, b) in results if a == player_a))
better_than_b = set((a for (a, b) in results if b == player_b))
if len(worse_than_a.intersection(better_than_b)) > 0:
	print('%d %d' % (player_a, player_b))
else:
	print('%d %d' % (player_b, player_a))


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
IN = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def s(a):
	print(' '.join(list(map(str, a))))
n = I()
x = int(n * (n - 1) // 2) - 1
a = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(x):
	(x, y) = M()
	a[x] += 1
	a[y] += 1
	b[x] += 1
c = []
for i in range(1, n + 1):
	if a[i] == n - 2:
		c.append(i)
if b[c[0]] == b[c[1]]:
	print(min(c), max(c))
elif b[c[0]] > b[c[1]]:
	print(c[0], c[1])
else:
	print(c[1], c[0])


a = int(input())
z = [[0] * (a + 1) for _ in ' ' * (a + 1)]
p = [0] * (a + 1)
for _ in ' ' * (a * (a - 1) // 2 - 1):
	(u, v) = map(int, input().split())
	p += [[u, v]]
	z[u][v] = 1
	p[u] += 1
	p[v] += 1
for i in range(1, a + 1):
	for j in range(1, a + 1):
		for k in range(1, a + 1):
			if z[i][j] == 1 and z[j][k] == 1:
				z[i][k] = 1
gh = []
for i in range(1, a + 1):
	if p[i] < a - 1:
		gh.append(i)
if z[gh[0]][gh[1]]:
	print(gh[0], gh[1])
else:
	print(gh[1], gh[0])


num = int(input())
win = []
dic = {}
for i in range(1, num + 1):
	dic[i] = num - 1
for i in range(int(num * (num - 1) / 2) - 1):
	p = input().split()
	win.append(int(p[0]))
	dic[int(p[0])] -= 1
	dic[int(p[1])] -= 1
k = []
for i in range(1, num + 1):
	if dic[i] != 0:
		k.append(i)
a = win.count(k[0])
b = win.count(k[1])
if a >= b:
	print(k[0], k[1])
else:
	print(k[1], k[0])


def solution():
	n = int(input())
	cnt = {}
	for i in range(n * (n - 1) // 2 - 1):
		player = [int(i) for i in input().split()]
		if player[0] in cnt:
			cnt[player[0]][0].append(player[1])
		else:
			cnt[player[0]] = [[player[1]], []]
		if player[1] in cnt:
			cnt[player[1]][1].append(player[0])
		else:
			cnt[player[1]] = [[], [player[0]]]
	res = []
	for i in cnt:
		if len(cnt[i][0]) + len(cnt[i][1]) < n - 1:
			res.append(i)
	queue = [res[0]]
	head = 0
	visited = {res[0]}
	while head < len(queue):
		if queue[head] == res[1]:
			print(res[0], res[1])
			break
		for i in cnt[queue[head]][0]:
			if i not in visited:
				visited.add(i)
				queue.append(i)
		head += 1
	else:
		print(res[1], res[0])
solution()


import os
import sys
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

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

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
sleep = defaultdict(int)
over = defaultdict(int)
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = value()
	sleep[x] += 1
	over[x] += 1
	over[y] += 1
have = set()
left = []
for i in range(1, n + 1):
	if over[i] != n - 1:
		left.append(i)
	else:
		have.add(sleep[i])
(p1, p2) = left
if sleep[p1] in have:
	print(p1, p2)
elif sleep[p2] in have:
	print(p2, p1)
elif sleep[p1] + 1 in have:
	print(p2, p1)
else:
	print(p1, p2)


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 = iinput()
till = n * (n - 1) // 2
times = [0] * (n + 1)
lists = []
for _ in range(1, till):
	(u, v) = rinput()
	lists.append([u, v])
	times[u] += 1
	times[v] += 1
left = []
for i in range(1, n + 1):
	if times[i] == n - 2:
		left.append(i)
for i in range(len(lists)):
	(u, v) = lists[i]
	if u == left[0]:
		if [v, left[1]] in lists[i + 1:]:
			print(*left)
			break
	if u == left[1]:
		if [v, left[0]] in lists[i + 1:]:
			print(*left[::-1])
			break
	if v == left[0]:
		if [left[1], u] in lists[i + 1:]:
			print(*left[::-1])
			break
	if v == left[1]:
		if [left[0], u] in lists[i + 1:]:
			print(*left)
			break
else:
	print(*left)


a = int(input())
z = a * (a - 1) // 2 - 1
k = []
for i in range(a):
	k.append([0] * a)
for i in range(z):
	(u, v) = map(int, input().split())
	u -= 1
	v -= 1
	k[u][v] = 1
	k[v][u] = -1
(x, y) = (0, 0)
for i in range(a):
	for j in range(1 + i, a):
		if k[i][j] == 0:
			(x, y) = (i, j)
ok = False
for t in range(a):
	if k[x][t] == 1 and k[t][y] == 1:
		ok = True
if ok:
	print(x + 1, y + 1)
else:
	print(1 + y, 1 + x)


n = int(input())
hash = {}
total = n * (n - 1) // 2
each = n - 1
l = []
hash_team = {}
for i in range(n):
	hash[i + 1] = 0
	hash_team[i + 1] = False
for i in range(total - 1):
	(x, y) = map(int, input().split())
	l.append([x, y])
	hash[x] += 1
	hash[y] += 1
ans = []
for i in hash.keys():
	if hash[i] != each:
		ans.append(i)
ba = []
for i in range(total - 1):
	(x, y) = l[i]
	if x == ans[0]:
		hash_team[y] = True
	if x == ans[1]:
		ba.append(y)
flag = 0
for i in ba:
	if hash_team[i] == False:
		print(ans[1], ans[0])
		flag = 1
		break
if flag == 0:
	print(*ans)


from sys import stdin, stdout
n = int(stdin.readline())
vertices = [[] for i in range(n + 1)]
challengers = {(i, j) for i in range(1, n + 1) for j in range(i + 1, n + 1)}
for i in range(n * (n - 1) // 2 - 1):
	(a, b) = map(int, stdin.readline().split())
	vertices[a].append(b)
	challengers.discard((a, b))
	challengers.discard((b, a))
(first, second) = list(challengers)[0]
visit = [0 for i in range(n + 1)]

def dfs(v):
	visit[v] = 1
	for u in vertices[v]:
		if not visit[u]:
			dfs(u)
dfs(first)
if visit[second]:
	stdout.write(str(first) + ' ' + str(second))
else:
	stdout.write(str(second) + ' ' + str(first))


n = int(input())
x = n * (n - 1) // 2 - 1
arr = {}
arr2 = {}
arr3 = []
for _ in range(x):
	(a, b) = map(int, input().split())
	if a in arr:
		arr[a].append(b)
	else:
		arr[a] = [b]
	if a in arr2:
		arr2[a].append(b)
	else:
		arr2[a] = [b]
	if b in arr2:
		arr2[b].append(a)
	else:
		arr2[b] = [a]
count = 0
for k in arr2:
	if len(arr2[k]) == n - 2:
		arr3.append(k)
		count += 1
	if count == 2:
		break
(u, v) = arr3
if u in arr and v in arr:
	if len(arr[u]) > len(arr[v]):
		print(u, v)
	else:
		print(v, u)
elif u in arr:
	print(u, v)
else:
	print(v, u)


n = int(input())
m = n * (n - 1) // 2
p = [[] for i in range(n + 1)]
t = [0] * (n + 1)
for i in range(m - 1):
	(a, b) = map(int, input().split())
	p[a].append(b)
	t[a] += 1
	t[b] += 1
x = 1 + t[1:].index(n - 2)
y = x + 1 + t[x + 1:].index(n - 2)
t = [True] * (n + 1)
r = p[x]
while r:
	j = r.pop()
	for i in p[j]:
		if i == y:
			r = True
			break
		if t[i]:
			r.append(i)
			t[i] = False
	if r == True:
		break
if r:
	print(x, y)
else:
	print(y, x)


def main():
	n = int(input())
	l = [{'loss': [], 'win': []} for i in range(n)]
	k = [0 for _ in range(n)]
	won = [0 for _ in range(n)]
	for i in range(n * (n - 1) // 2 - 1):
		(x, y) = tuple(map(int, input().split()))
		l[y - 1]['loss'] += [x]
		l[x - 1]['win'] += [y]
		won[x - 1] += 1
		k[x - 1] += 1
		k[y - 1] += 1
	i = 0
	j = 0
	while n - 2 in k:
		i = k.index(n - 2)
		k.remove(n - 2)
		j = k.index(n - 2) + 1
		k.remove(n - 2)
	if won[i] > won[j]:
		print(i + 1, j + 1)
	else:
		print(j + 1, i + 1)
main()


def readln():
	return tuple(map(int, input().split()))
(n,) = readln()
cnt = [0] * n
win = [0] * n
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = readln()
	cnt[x - 1] += 1
	win[x - 1] += 1
	cnt[y - 1] += 1
(a, b) = [i for (i, j) in zip(range(n), cnt) if j < n - 1][:2]
if win[a] > win[b]:
	print(a + 1, b + 1)
else:
	print(b + 1, a + 1)


n = int(input())
s = set()
a = [0] * n
cnt = [0] * n
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	a[x - 1] += 1
	a[y - 1] -= 1
	cnt[x - 1] += 1
	cnt[y - 1] += 1
r = []
for i in range(n):
	if cnt[i] == n - 2:
		r.append((a[i], i + 1))
r.sort()
print(r[1][1], r[0][1])


from collections import defaultdict
n = int(input())
d = defaultdict(list)
m = n * (n - 1) // 2
cnt = [0] * 100
play = m * 2 // n
for i in range(1, m):
	(a, b) = map(int, input().split())
	d[a].append(b)
	cnt[a] += 1
	cnt[b] += 1
ans = []
for i in range(1, n + 1):
	if cnt[i] < play:
		ans.append(i)
p1 = ans[0]
q = [p1]
vis = [0] * (n + 1)
while q:
	t = q.pop(0)
	for i in d[t]:
		if not vis[i]:
			vis[i] = 1
			q.append(i)
if vis[ans[1]]:
	print(ans[0], ans[1])
	exit()
print(ans[1], ans[0])


def s():
	n = int(input())
	a = [0] * (n + 1)
	b = [0] * (n + 1)
	r = []
	for _ in range(n * (n - 1) // 2 - 1):
		c = list(map(int, input().split()))
		a[c[0]] += 1
		b[c[1]] += 1
	for i in range(1, n + 1):
		if a[i] + b[i] == n - 2:
			r.append(i)
	r.sort(key=lambda x: -a[x])
	print(*r)
s()


n = int(input())
(a, b, c) = ([0] * (n + 1), [0] * (n + 1), [])
for _ in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	a[x] += 1
	b[y] += 1
for i in range(1, n + 1):
	if a[i] + b[i] != n - 1:
		c.append(i)
if a[c[0]] > a[c[1]]:
	print(c[0], c[1])
else:
	print(c[1], c[0])


n = int(input())
l1 = []
l4 = []
c = int(n * (n - 1) / 2 - 1)
for i in range(0, c):
	l2 = list(map(int, input().split()))
	l1.append(l2[0])
	l4.append(l2[1])
d1 = {}
d2 = {}
for x in range(1, n + 1):
	d1[x] = 0
for x in range(1, n + 1):
	d2[x] = 0
for x in l1:
	d1[x] = d1[x] + 1
for x in l4:
	d2[x] = d2[x] + 1
l3 = []
c = 0
for x in d1:
	if c == 2:
		break
	elif d1[x] + d2[x] == n - 2:
		l3.append(x)
		c = c + 1
if d1[l3[0]] > d1[l3[1]]:
	print(str(l3[0]) + ' ' + str(l3[1]))
else:
	print(str(l3[1]) + ' ' + str(l3[0]))


n = int(input())
freq = {}
wins = {}
for i in range(1, n + 1):
	freq[i] = 0
	wins[i] = 0
for i in range(n * (n - 1) // 2 - 1):
	(a, b) = [int(p) for p in input().split()]
	freq[a] += 1
	freq[b] += 1
	wins[a] += 1
final = []
for i in freq:
	if freq[i] != n - 1:
		final.append(i)
if wins[final[0]] >= wins[final[1]]:
	print(*final)
else:
	print(final[1], final[0])


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy
import re
import string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby, count, filterfalse
from operator import itemgetter
l = []
l1 = []
n = II()
lst = []
for _ in range(n * (n - 1) // 2 - 1):
	(x, y) = LI()
	l.append(x)
	l1.append(y)
c = Counter(l)
c1 = Counter(l1)
z = l + l1
z = Counter(z)
for (k, v) in z.items():
	if v != n - 1:
		lst.append(k)
if c[lst[0]] > c[lst[1]]:
	print(lst[0], lst[1])
else:
	print(lst[1], lst[0])


n = int(input())
L = [0 for i in range(n + 1)]
wins = {}
p = n * (n - 1) // 2 - 1
for i in range(p):
	(a, b) = map(int, input().split())
	L[a] += 1
	L[b] += 1
	if a in wins:
		wins[a].append(b)
	else:
		wins[a] = [b]
M = []
for i in range(1, n + 1):
	if L[i] < n - 1:
		M.append(i)
m1 = M[0]
m2 = M[1]
co = False
pushed = []
if m1 not in wins:
	print(m2, m1)
else:
	while len(wins[m1]) != 0 and (not co):
		k = wins[m1][0]
		if k == m2:
			co = True
		elif k in pushed:
			wins[m1] = wins[m1][1:]
		else:
			pushed.append(k)
			if k in wins:
				wins[m1] = wins[m1][1:] + wins[k]
			else:
				wins[m1] = wins[m1][1:]
	if co:
		print(m1, m2)
	else:
		print(m2, m1)


n = int(input())
a = []
for i in range(n * (n - 1) // 2 - 1):
	(c, d) = map(int, input().split())
	a.append([c, d])
d = {}
for i in a:
	if i[0] in d:
		d[i[0]] += 1
	else:
		d[i[0]] = 1
	if i[1] in d:
		d[i[1]] += 1
	else:
		d[i[1]] = 1
c = []
for i in d:
	if d[i] != n - 1:
		c.append(i)
win = []
loss = []
win1 = []
loss1 = []
for i in a:
	if i[0] == c[0]:
		win.append(i[1])
	elif i[1] == c[0]:
		loss.append(i[0])
	if i[0] == c[1]:
		win1.append(i[1])
	elif i[1] == c[1]:
		loss1.append(i[0])
flag = 0
for i in win:
	for j in loss1:
		if i == j:
			flag = 1
			print(c[0], c[1])
			break
	if flag:
		break
if not flag:
	for i in loss:
		for j in win1:
			if i == j:
				print(c[1], c[0])
				flag = 1
				break
		if flag:
			break
if not flag:
	print(c[0], c[1])


from collections import defaultdict
n = int(input())
d = [[[], []] for i in range(n + 1)]
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	d[x][1].append(y)
	d[y][0].append(x)
flag = 0
for j in range(1, n + 1):
	if len(d[j][0]) + len(d[j][1]) < n - 1:
		for k in range(1, n + 1):
			if k == j or k in d[j][0] or k in d[j][1]:
				continue
			else:
				s1 = j
				s2 = k
				flag = 1
				break
	if flag == 1:
		break
for i in range(1, n + 1):
	if i == s1 or i == s2:
		continue
	else:
		if i in d[s1][1] and i in d[s2][0]:
			print(s1, s2)
			exit()
		if i in d[s1][0] and i in d[s2][1]:
			print(s2, s1)
			exit()
print(s1, s2)


n = int(input())
l = []
d = dict()
dp = dict()
for i in range(1, n + 1):
	d[i] = 0
	dp[i] = []
for i in range(1, n * (n - 1) // 2):
	(a, b) = map(int, input().split())
	d[a] += 1
	d[b] += 1
	dp[a].append(b)
(x, y) = (-1, -1)
for i in d:
	if d[i] == n - 1:
		continue
	if x == -1:
		x = i
	else:
		y = i
		break
stack = [x]
visited = set()
while stack:
	z = stack.pop()
	if z in visited:
		continue
	visited.add(z)
	if z == y:
		print(x, y)
		exit()
	for item in dp[z]:
		stack.append(item)
print(y, x)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
n = inn()
to = n * (n - 1) // 2
win = defaultdict(list)
lose = defaultdict(list)
for i in range(to - 1):
	(x, y) = value()
	win[x] += [y]
	lose[y] += [x]
ans = []
for i in range(1, n + 1):
	if len(win[i]) + len(lose[i]) != n - 1:
		ans += [i]
winner = ans[0]
loser = ans[1]
for i in range(1, n + 1):
	if i in win[ans[0]] and i in lose[ans[1]]:
		winner = ans[0]
		loser = ans[1]
		break
	if i in lose[ans[0]] and i in win[ans[1]]:
		winner = ans[1]
		loser = ans[0]
		break
print(winner, loser)


def bfs(graph, source, destination):
	queue = [source]
	visited = {source: True}
	while queue:
		s = queue.pop(0)
		if graph.get(s) != None:
			for node in graph[s]:
				if visited.get(node) == None:
					visited[node] = True
					queue.append(node)
	return visited.get(destination)
n = int(input())
m = n * (n - 1) // 2 - 1
graph = {}
a = [0] * (n + 1)
missing = []
for _ in range(m):
	(u, v) = map(int, input().split())
	graph.setdefault(u, []).append(v)
	a[u] += 1
	a[v] += 1
for i in range(1, n + 1):
	if a[i] == n - 2:
		missing.append(i)
if bfs(graph, missing[0], missing[1]):
	print(missing[0], missing[1])
else:
	print(missing[1], missing[0])


def isWinner(x, y, visited, graph):
	if x == y:
		return True
	visited.append(x)
	for i in range(len(graph[x])):
		if graph[x][i] and i not in visited and isWinner(i, y, visited, graph):
			return True
	return False
n = int(input())
graph = [[0] * (n + 1) for _ in range(n + 1)]
a = [0] * (n + 1)
l = []
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	graph[x][y] = 1
	a[x] += 1
	a[y] += 1
for i in range(1, n + 1):
	if a[i] < n - 1:
		l.append(i)
if isWinner(l[0], l[1], [0] * (n + 1), graph):
	print(l[0], l[1])
elif isWinner(l[1], l[0], [0] * (n + 1), graph):
	print(l[1], l[0])
else:
	print(l[0], l[1])


n = int(input())
a = [0] * n
for c in range(n * (n - 1) // 2 - 1):
	(x, y) = map(int, input().split())
	a[x - 1] += 1
	a[y - 1] -= 1
r = []
for i in range(n):
	if a[i] & 1 != n - 1 & 1:
		r.append((a[i], i + 1))
r.sort()
print(r[1][1], r[0][1])


n = int(input())
mas = {}
res = []
for i in range(n * (n - 1) // 2 - 1):
	buf = input().split()
	if buf[0] in mas:
		mas[buf[0]][0] += 1
		mas[buf[0]][1] += 1
	else:
		mas[buf[0]] = [1, 1]
	if buf[1] in mas:
		mas[buf[1]][0] += 1
	else:
		mas[buf[1]] = [1, 0]
for k in mas:
	if mas[k][0] != n - 1:
		res.append((k, mas[k][1]))
if res[0][1] > res[1][1]:
	print(res[0][0] + ' ' + res[1][0])
else:
	print(res[1][0] + ' ' + res[0][0])


(winner, loser, amount, people, currmax) = ({}, {}, {}, int(input()), 0)
for line in range(int(people * (people - 1) / 2) - 1):
	(w, l) = list(map(int, input().split(' ')))
	if w in winner:
		winner[w].append(l)
	else:
		winner[w] = [l]
	if l in loser:
		loser[l].append(w)
	else:
		loser[l] = [w]
	if w not in amount:
		amount[w] = 1
	else:
		amount[w] += 1
	if l not in amount:
		amount[l] = 1
	else:
		amount[l] += 1
	if amount[l] > currmax:
		currmax = amount[l]
	if amount[w] > currmax:
		currmax = amount[w]
toprint = ''
lost = [x for x in amount.keys() if amount[x] < currmax]
if lost[0] in winner:
	for key in winner[lost[0]]:
		if key in winner and lost[1] in winner[key]:
			toprint = str(lost[0]) + ' ' + str(lost[1])
			break
if toprint == '' and lost[1] in winner:
	for key in winner[lost[1]]:
		if key in winner and lost[0] in winner[key]:
			toprint = str(lost[1]) + ' ' + str(lost[0])
			break
if toprint == '':
	toprint = str(lost[0]) + ' ' + str(lost[1])
print(toprint)


n = int(input())
a = [[] for i in range(n + 1)]
b = [0 for i in range(n + 1)]
for i in range(1, n * (n - 1) // 2):
	(x, y) = map(int, input().split())
	a[x].append(y)
	b[x] += 1
	b[y] += 1
x = 0
y = 0
for i in range(n + 1):
	if b[i] == n - 2:
		if x == 0:
			x = i
		else:
			y = i
b = False
for i in a[x]:
	for j in a[i]:
		if j == y:
			b = True
if b:
	print(x, y)
else:
	print(y, x)


from sys import *
from bisect import *
from collections import *
from itertools import *
from fractions import *
from datetime import *
from math import *
Input = []

def Out(x):
	stdout.write(str(x) + '\n')

def In():
	return stdin.readline().strip()

def inputGrab():
	for line in stdin:
		Input.extend(map(str, line.strip().split()))
Win = []

def recur(x, y):
	input()
	print(x, y, end=' ')
	print(Win[x])
	for elem in Win[x]:
		if elem == y:
			return 1
		recur(elem, y)
	return 0

def main():
	n = int(In())
	cnt = [0] * (n + 1)
	t = n * (n - 1) // 2 - 1
	Streak = [0 for _ in range(n + 2)]
	Set = set()
	for _ in range(n + 1):
		Win.append(set())
	for _ in range(t):
		(x, y) = map(int, In().split())
		Win[x].add(y)
		cnt[x] += 1
		cnt[y] += 1
	x = -1
	y = -1
	for i in range(1, n + 1):
		if cnt[i] < n - 1:
			if x == -1:
				x = i
			else:
				y = i
	if len(Win[x]) > len(Win[y]):
		print(x, y)
	else:
		print(y, x)
main()


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
n = int(I1())
No_play = [0] * (n + 1)
w = [0] * (n + 1)
for i in range(n * (n - 1) // 2 - 1):
	(x, y) = I()
	No_play[x] += 1
	No_play[y] += 1
	w[x] += 1
x = y = -1
for i in range(1, n + 1):
	if No_play[i] == n - 2:
		if x != -1:
			y = i
			break
		x = i
if w[x] > w[y]:
	print(x, y)
else:
	print(y, x)


testcases = int(input())
n = testcases
import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
winner = [[] for _ in range(n)]
losser = [[] for _ in range(n)]
dicts = {}
tt = n * (n - 1) // 2 - 1
for testcase in range(tt):
	arr = get_ints()
	ww = arr[0] - 1
	ll = arr[1] - 1
	winner[ww].append(ll)
	losser[ll].append(ww)
	if ww not in dicts:
		dicts[ww] = 1
	else:
		dicts[ww] += 1
	if ll not in dicts:
		dicts[ll] = 1
	else:
		dicts[ll] += 1
for i in range(n):
	if i not in dicts:
		dicts[i] = 0
missarr = []
mins = 939393939
for (key, value) in dicts.items():
	if value < mins:
		mins = value
for (key, value) in dicts.items():
	if value == mins:
		missarr.append(key)
first = missarr[0]
sec = missarr[1]
firstwinner = {}
firstloser = {}
secwinner = {}
secloser = {}
for i in winner[first]:
	firstwinner[i] = 1
for i in losser[first]:
	firstloser[i] = 1
for i in winner[sec]:
	secwinner[i] = 1
for i in losser[sec]:
	secloser[i] = 1
flag = 0
if len(firstloser) == 0:
	print(str(first + 1) + ' ' + str(sec + 1))
	flag = 1
elif len(secloser) == 0:
	print(str(sec + 1) + ' ' + str(first + 1))
	flag = 1
if flag == 0:
	flag2 = 0
	for (key, value) in firstwinner.items():
		if key in secloser:
			flag2 = 1
			break
	if flag2 == 1:
		print(str(first + 1) + ' ' + str(sec + 1))
	else:
		print(str(sec + 1) + ' ' + str(first + 1))


n = int(input())
graph = {i: [] for i in range(1, n + 1)}
counter = [0] * (n + 1)
for _ in range(n * (n - 1) // 2 - 1):
	(a, b) = map(int, input().split())
	counter[a] += 1
	counter[b] += 1
	graph[a].append(b)
c = [t for t in range(1, n + 1) if counter[t] == n - 2]
for k in range(1, n + 1):
	if k == c[0] or k == c[1]:
		continue
	if k in graph[c[0]] and c[1] in graph[k]:
		print(c[0], c[1])
		break
	if k in graph[c[1]] and c[0] in graph[k]:
		print(c[1], c[0])
		break
else:
	print(c[0], c[1])


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n * (n - 1) // 2 - 1):
	(c, d) = list(map(int, input().split()))
	a[c - 1] += 1
	b[c - 1] += 1
	b[d - 1] += 1
f = -1
g = -1
for i in range(n):
	if b[i] == n - 2:
		if f == -1:
			f = i + 1
		else:
			g = i + 1
			break
if a[f - 1] > a[g - 1]:
	print(f, g)
else:
	print(g, f)