There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.

Every contestant hopes that he can find a teammate so that their team’s strength is as high as possible. That is, a contestant will form a team with highest strength possible by choosing a teammate from ones who are willing to be a teammate with him/her. More formally, two people A and B may form a team if each of them is the best possible teammate (among the contestants that remain unpaired) for the other one. 

Can you determine who will be each person’s teammate?


-----Input-----

There are 2n lines in the input. 

The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed.

The i-th line (i > 1) contains i - 1 numbers a_{i}1, a_{i}2, ... , a_{i}(i - 1). Here a_{ij} (1 ≤ a_{ij} ≤ 10^6, all a_{ij} are distinct) denotes the strength of a team consisting of person i and person j (people are numbered starting from 1.)


-----Output-----

Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.


-----Examples-----
Input
2
6
1 2
3 4 5

Output
2 1 4 3

Input
3
487060
3831 161856
845957 794650 976977
83847 50566 691206 498447
698377 156232 59015 382455 626960

Output
6 5 4 3 2 1



-----Note-----

In the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.

Difficulty: EASY
Tags: Sorting

Implementation

Complete search
Skill types: Sorting

Complete search

Starter code:

Solutions:
def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	if mode == 'file':
		n = int(f.readline())
	else:
		n = int(input())
	w = []
	for i in range(2, 2 * n + 1):
		if mode == 'file':
			g = [int(x) for x in f.readline().split()]
		else:
			g = [int(x) for x in input().split()]
		for j in range(1, i):
			w.append([g[j - 1], [i, j]])
	w.sort()
	free = 2 * n
	fr = [-1] * (free + 1)
	w.reverse()
	for (e, k) in w:
		if fr[k[0]] == -1 and fr[k[1]] == -1:
			fr[k[0]] = k[1]
			fr[k[1]] = k[0]
			free -= 1
			if free == 0:
				break
	for i in fr[1:]:
		print(i, end=' ')
	if mode == 'file':
		f.close()

def __starting_point():
	main()
__starting_point()


n = int(input()) * 2
matriz = [[-float('inf') for i in range(n)] for j in range(n)]
for i in range(1, n):
	a = [int(k) for k in input().split()]
	for j in range(len(a)):
		matriz[i][j] = a[j]
best_i = [-1 for i in range(n)]
pares = []
for i in range(n):
	for j in range(n):
		if matriz[i][j] != -float('inf'):
			pares.append((matriz[i][j], i, j))
pares.sort(key=lambda tup: -tup[0])
dispo = set([int(i) for i in range(n)])
for (valor, i, j) in pares:
	if not i in dispo or not j in dispo:
		continue
	else:
		best_i[i] = j
		best_i[j] = i
		dispo.remove(i)
		dispo.remove(j)
for i in range(n):
	print(best_i[i] + 1, end='')
	if i < n - 1:
		print(end=' ')
print()


x = int(input())
possib = []
for i in range(1, x * 2):
	t = input().split()
	for j in range(len(t)):
		possib.append([int(t[j]), i + 1, j + 1])
times = [''] * (x * 2)
cont = x * 2
possib.sort(reverse=True)
i = 0
while cont:
	maior = possib[i]
	time = (possib[i][1], possib[i][2])
	t1 = str(possib[i][1])
	t2 = str(possib[i][2])
	if t1 not in times and t2 not in times:
		times[possib[i][1] - 1] = t2
		times[possib[i][2] - 1] = t1
		cont -= 2
	i += 1
print(' '.join(times) + '\n')


a = int(input())
z = []
for i in range(2, 2 * a + 1):
	for (j, k) in enumerate(map(int, input().split())):
		z.append([k, i, j + 1])
k = [0] * (2 * a + 1)
for i in sorted(z)[::-1]:
	if k[i[1]] == 0 and k[i[2]] == 0:
		k[i[1]] = i[2]
		k[i[2]] = i[1]
print(*k[1:])


import sys
N = int(input())
score_pairings = []
partner_of = {}
people_with_partners = set()
for k in range(2 * N - 1):
	i = k + 2
	line = list(map(int, input().split()))
	for j in range(1, i):
		score_pairings += [(line[j - 1], (i, j))]
score_pairings = sorted(score_pairings)[::-1]
for (score, (i, j)) in score_pairings:
	if i in people_with_partners or j in people_with_partners:
		continue
	partner_of[i] = j
	partner_of[j] = i
	people_with_partners.add(i)
	people_with_partners.add(j)
print(' '.join((str(partner_of[i]) for i in partner_of)))


n = int(input())
tuples = []
for i in range(2 * n - 1):
	for (j, score) in enumerate(map(int, input().split())):
		tuples.append((-score, i + 1, j))
tuples.sort()
result = 2 * n * [None]
for (score, i, j) in tuples:
	if result[i] == None and result[j] == None:
		result[i] = j + 1
		result[j] = i + 1
print(' '.join(map(str, result)))


import unittest
import sys

class Member:

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else input().rstrip()
		[self.n] = map(int, uinput().split())
		self.nums = []
		for i in range(self.n * 2 - 1):
			self.nums.append(list(map(int, uinput().split())))
		self.pairs = []
		for i in range(len(self.nums)):
			for j in range(len(self.nums[i])):
				self.pairs.append((self.nums[i][j], i + 1, j))
		self.spairs = reversed(sorted(self.pairs))

	def calculate(self):
		result = [0] * (self.n * 2)
		paired = set()
		for p in self.spairs:
			if p[1] not in paired and p[2] not in paired:
				result[p[1]] = p[2] + 1
				result[p[2]] = p[1] + 1
				paired.add(p[1])
				paired.add(p[2])
		return str(' '.join(map(str, result)))

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '2\n6\n1 2\n3 4 5'
		d = Member(test)
		self.assertEqual(d.n, 2)
		self.assertEqual(d.nums[0], [6])
		self.assertEqual(d.nums[1], [1, 2])
		self.assertEqual(Member(test).calculate(), '2 1 4 3')
		test = '3\n487060\n3831 161856\n845957 794650 976977\n' + '83847 50566 691206 498447\n' + '698377 156232 59015 382455 626960'
		self.assertEqual(Member(test).calculate(), '6 5 4 3 2 1')
		test = ''
		test = ''

	def time_limit_test(self, nmax):
		import random
		import timeit
		test = str(nmax) + ' ' + str(nmax) + '\n'
		numnums = [str(i) + ' ' + str(i + 1) for i in range(nmax)]
		test += '\n'.join(numnums) + '\n'
		nums = [random.randint(1, 10000) for i in range(nmax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = Member(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(Member().calculate())


n = int(input())
scores = []
for i in range(1, 2 * n):
	values = list(map(int, input().split()))
	for j in range(len(values)):
		scores.append((values[j], i + 1, j + 1))
scores.sort(reverse=True)
ans = [0] * (2 * n + 1)
for i in range(0, len(scores)):
	if ans[scores[i][1]] != 0 or ans[scores[i][2]] != 0:
		continue
	ans[scores[i][1]] = scores[i][2]
	ans[scores[i][2]] = scores[i][1]
print(' '.join((str(ans[i]) for i in range(1, 2 * n + 1))))


n = int(input())
res = []
t = [-1] * 2 * n
for i in range(2 * n - 1):
	l = list(map(int, input().split()))
	for (j, x) in enumerate(l):
		res.append([x, i + 1, j])
res.sort(reverse=True)
for (x, i, j) in res:
	if t[i] == t[j] == -1:
		t[i] = j + 1
		t[j] = i + 1
print(*t)


n = int(input())
N = 2 * n
ans = [None] * N
a = [list(map(int, input().split())) for i in range(N - 1)]
used = [False] * N
inf = 10 ** 9
for i in range(n):
	Max = -inf
	for i in range(N - 1):
		if not used[i + 1]:
			for j in range(i + 1):
				if not used[j] and a[i][j] > Max:
					Max = a[i][j]
					(x, y) = (i + 1, j)
	used[x] = True
	used[y] = True
	ans[x] = y + 1
	ans[y] = x + 1
print(' '.join(map(str, ans)))


n = int(input())
out = [-1] * n * 2
L = []
for i in range(1, n * 2):
	l = list(map(int, input().split()))
	for j in range(len(l)):
		t = [l[j], [i + 1, j + 1]]
		L.append(t)
L = sorted(L, key=lambda x: -x[0])
for i in range(len(L)):
	if out[L[i][1][0] - 1] == out[L[i][1][1] - 1] == -1:
		out[L[i][1][0] - 1] = L[i][1][1]
		out[L[i][1][1] - 1] = L[i][1][0]
print(' '.join(map(str, out)))


from heapq import heapify
from heapq import heappop

def cmp(a, b):
	return a[0] > a[1]
n = int(input())
arr = []
for i in range(n * 2):
	arr.append([None] * (n * 2))
elems = []
for i in range(1, n * 2):
	lst = list(map(int, input().split()))
	for j in range(len(lst)):
		elems.append([-lst[j], i, j])
heapify(elems)
players = [True] * (n * 2)
rez = [None] * (n * 2)
cnt = 0
while elems and cnt != n:
	(w, a, b) = heappop(elems)
	if players[a] and players[b]:
		players[a] = False
		players[b] = False
		cnt += 1
		rez[a] = b
		rez[b] = a
for i in range(n * 2):
	print(rez[i] + 1, end=' ')


import operator
n = int(input())
dict = {}
for i in range(2, 2 * n + 1):
	L = list(map(int, input().split()))
	for j in range(len(L)):
		dict[L[j]] = (i, j + 1)
sorted_dict = sorted(dict.items(), key=operator.itemgetter(0), reverse=True)
ans = [0] * 2 * n
for i in sorted_dict:
	if ans[i[1][0] - 1] == 0 and ans[i[1][1] - 1] == 0:
		ans[i[1][0] - 1] = i[1][1]
		ans[i[1][1] - 1] = i[1][0]
print(' '.join(map(str, ans)))


n = int(input())
comrade = [0 for i in range(2 * n)]
edges = []
for i in range(1, 2 * n):
	edges.extend([(-int(x), i, j) for (j, x) in enumerate(input().split())])
edges.sort()
for e in edges:
	(x, i, j) = e
	if not comrade[i] and (not comrade[j]):
		comrade[i] = str(j + 1)
		comrade[j] = str(i + 1)
print(' '.join(comrade))


n = int(input())
a = []
b = [0] * (2 * n + 1)
c = [0] * (2 * n + 1)
z = dict()
for i in range(2 * n - 1):
	k = list(map(int, input().split()))
	for j in range(len(k)):
		z[k[j]] = (i + 2, j + 1)
	a += k
a.sort(reverse=True)
for d in range(len(a)):
	(i, j) = z[a[d]]
	if not c[i] and (not c[j]):
		b[i] = j
		b[j] = i
		c[i] = c[j] = True
for i in range(1, 2 * n + 1):
	print(b[i], end=' ')


n = int(input())
strength = []
for i in range(1, n * 2):
	ss = list(map(int, input().split()))
	for (j, s) in enumerate(ss):
		strength.append((s, i, j))
strength.sort(reverse=True)
team_mates = [0] * (2 * n)
counter = 0
for (s, i, j) in strength:
	if team_mates[i] or team_mates[j]:
		continue
	team_mates[i] = j + 1
	team_mates[j] = i + 1
	counter += 1
	if counter == n:
		break
print(*team_mates)


n = 2 * int(input())
weight_to_pair = {}
for i in range(2, n + 1):
	weights = list(map(int, input().split()))
	for j in range(1, i):
		weight_to_pair[weights[j - 1]] = (j, i)
teammate = {}
for (weight, pair) in reversed(sorted(weight_to_pair.items())):
	(a, b) = pair
	if a in teammate or b in teammate:
		continue
	teammate[a] = b
	teammate[b] = a
print(' '.join(map(str, [teammate[i] for i in range(1, n + 1)])))


import sys
N = int(sys.stdin.readline())
members = list()
list_sum = list()
for i in range(2 * N - 1):
	members.append(list(map(int, sys.stdin.readline().split())))
	for j in range(len(members[i])):
		list_sum.append([members[i][j], (i + 2, j + 1)])
list_sum.sort(key=lambda x: x[0], reverse=True)
members_set = set()
teammates = [0] * 2 * N
for one_list in list_sum:
	if N == 0:
		break
	elif one_list[1][0] not in members_set and one_list[1][1] not in members_set:
		members_set.add(one_list[1][0])
		members_set.add(one_list[1][1])
		teammates[one_list[1][0] - 1] = one_list[1][1]
		teammates[one_list[1][1] - 1] = one_list[1][0]
		N -= 1
		continue
print(' '.join((repr(e) for e in teammates)))


import sys
sys.setrecursionlimit(1000000)
import math

def solve():
	(n,) = rv()
	l = list()
	already = [-1] * (2 * n)
	for i in range(2 * n - 1):
		(temp,) = rl(1)
		for (j, val) in enumerate(temp):
			l.append((val, i + 1, j))
	l.sort(key=lambda x: -x[0])
	for tup in l:
		(f, s) = (tup[1], tup[2])
		if already[f] == -1 and already[s] == -1:
			already[f] = s
			already[s] = f
	print(' '.join(map(str, [val + 1 for val in already])))

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

def rl(n):
	return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
solve()


from itertools import chain, repeat
n = int(input())
teams = []
for i in range(2, 2 * n + 1):
	teams.extend(zip(map(int, input().split()), repeat(i), range(1, i)))
partners = {}
for team in sorted(teams, reverse=True):
	if team[1] in partners or team[2] in partners:
		continue
	partners[team[1]] = team[2]
	partners[team[2]] = team[1]
teams = []
for i in range(1, 2 * n + 1):
	teams.append(partners[i])
print(' '.join(map(str, teams)))


n = int(input())
prioridade = []
vis = set()
ans = [0] * (2 * n)
for i in range(2, 2 * n + 1):
	linha = tuple(map(int, input().split()))
	for j in range(1, i):
		prioridade.append((linha[j - 1], j, i))
prioridade.sort(reverse=True)
tamanho = 0
for time in prioridade:
	if not time[1] in vis and (not time[2] in vis):
		ans[time[1] - 1] = time[2]
		ans[time[2] - 1] = time[1]
		vis = vis.union({time[1], time[2]})
		tamanho += 1
		if tamanho == 2 * n:
			break
print(' '.join(map(str, ans)))


n = int(input())
combs = []
for i in range(2 * n - 1):
	arr = [int(value) for value in input().split()]
	for (j, value) in enumerate(arr):
		combs.append(tuple([value] + sorted([i + 2, j + 1])))
combs.sort(reverse=True)
ans = [0] * (2 * n + 1)
for (x, y, z) in combs:
	if ans[y] == 0 and ans[z] == 0:
		ans[y] = z
		ans[z] = y
for value in ans[1:]:
	print(value, end=' ')
print()


n = int(input())
l = []
for i in range(2, 2 * n + 1):
	if i == 2:
		s = [0, int(input())]
	else:
		s = [0] + list(map(int, input().split()))
	for j in range(1, i):
		l += [(s[j], i, j)]
l = sorted(l)
s = set()
k = [0] * (2 * n + 1)
for x in l[::-1]:
	if x[1] in s or x[2] in s:
		continue
	s |= {x[1], x[2]}
	k[x[1]] = x[2]
	k[x[2]] = x[1]
print(' '.join(map(str, k[1:])))


import sys
from operator import attrgetter
n = int(input())
possible_teams = []
used = [0 for i in range(0, 2 * n + 1)]
i = 2
while i <= 2 * n:
	line = sys.stdin.readline()
	str_nums = line.split(' ')
	j = 1
	for x in str_nums:
		possible_teams.append({'value': int(x), 'player1': i, 'player2': j})
		j += 1
	i += 1
possible_teams.sort(key=lambda x: x['value'], reverse=True)
i = 1
curr = 0
while i < n + 1:
	top = possible_teams[curr]
	p1 = top['player1']
	p2 = top['player2']
	if used[p1] == 0 and used[p2] == 0:
		used[p1] = p2
		used[p2] = p1
		i += 1
	curr += 1
for i in range(1, 2 * n + 1):
	print(used[i], end=' ')


from sys import stdin, stdout
n = int(stdin.readline())
a = []
b = [False] * 2 * n
for i in range(1, 2 * n):
	a += [[int(f), i] for f in stdin.readline().split()]
	for j in range(i):
		a[-i + j].append(j)
a.sort(reverse=True)
ans = []
for i in range(len(a)):
	if b[a[i][1]] == False and b[a[i][2]] == False:
		b[a[i][1]] = a[i][2] + 1
		b[a[i][2]] = a[i][1] + 1
print(*b)


n = int(input())
nums = []
people = [True] * 2 * n
pairs = [-1] * 2 * n
for i in range(1, 2 * n):
	i_nums = list(map(int, input().split()))
	nums += list(zip(i_nums, [i] * i, range(i)))
nums.sort(key=lambda x: x[0], reverse=True)
for (num, i, j) in nums:
	if people[i] and people[j]:
		people[i] = people[j] = False
		pairs[i] = str(j + 1)
		pairs[j] = str(i + 1)
print(' '.join(pairs))


n = int(input())
l = []
team = [-1] * 2 * n
for i in range(2 * n - 1):
	l2 = list(map(int, input().split()))
	for (j, x) in enumerate(l2):
		l.append([x, i + 1, j])
l = sorted(l, reverse=True)
for (x, i, j) in l:
	if team[i] == team[j] == -1:
		(team[i], team[j]) = (j, i)
print(' '.join((str(i + 1) for i in team)))


def main():
	n = int(input())
	(res, l) = ([0] * (n * 2), [])
	for i in range(1, n * 2):
		for (j, x) in enumerate(map(int, input().split())):
			l.append((x, j, i))
	l.sort(reverse=True)
	for (_, i, j) in l:
		if not (res[i] or res[j]):
			(res[i], res[j]) = (j + 1, i + 1)
	print(*res)
main()


n = int(input())
(g, res) = ([], [0] * (2 * n + 1))
for i in range(1, 2 * n):
	a = list(map(int, input().split()))
	for j in range(i):
		g.append([a[j], j + 1, i + 1])
for i in sorted(g, reverse=True):
	if not res[i[1]] and (not res[i[2]]):
		(res[i[1]], res[i[2]]) = (i[2], i[1])
print(*res[1:])


import itertools, functools, math

def solve():
	n = int(input())
	pairs = []
	for i in range(2 * n - 1):
		st = map(int, input().split())
		for (j, v) in enumerate(st):
			pairs.append((v, i + 1, j))
	matched = set()
	r = [None] * (2 * n)
	for (k, a, b) in sorted(pairs, reverse=True):
		if a in matched or b in matched:
			continue
		r[a] = b + 1
		r[b] = a + 1
		matched.add(a)
		matched.add(b)
	return r
print(*solve())


nTeams = int(input())
times = []
for i in range(2, 2 * nTeams + 1):
	forca = list(map(int, input().split()))
	j = 1
	for e in forca:
		times.append((e, i, j))
		j += 1
times.sort(reverse=True)
final = [[] for e in range(nTeams * 2)]
escolhidos = set()
for e in times:
	if e[1] not in escolhidos and e[2] not in escolhidos:
		escolhidos.add(e[1])
		escolhidos.add(e[2])
		final[e[1] - 1] = e[2]
		final[e[2] - 1] = e[1]
print(*final)


n = int(input())
data = list()
for i in range(1, 2 * n):
	s = input()
	k = list(map(int, s.split(' ')))
	m = len(k)
	for j in range(0, m):
		data.append((k[j], (i, j)))
data.sort(key=lambda d: d[0], reverse=True)
l = len(data)
memo = [-1] * (2 * n)
for i in range(0, l):
	(d0, d1) = data[i][1]
	if memo[d0] < 0 and memo[d1] < 0:
		memo[d0] = d1 + 1
		memo[d1] = d0 + 1
print(' '.join(map(str, memo)))


from heapq import *
n = int(input()) * 2
matriz = [[-float('inf') for i in range(n)] for j in range(n)]
pares = []
for i in range(1, n):
	a = [int(k) for k in input().split()]
	for j in range(len(a)):
		heappush(pares, (-a[j], i, j))
best_i = [-1 for i in range(n)]
for k in range(len(pares)):
	(valor, i, j) = heappop(pares)
	if best_i[i] != -1 or best_i[j] != -1:
		continue
	else:
		best_i[i] = j
		best_i[j] = i
for i in range(n):
	print(best_i[i] + 1, end='')
	if i < n - 1:
		print(end=' ')
print()


from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())

def main():
	n = ii()
	a = []
	m = {}
	for i in range(2, 2 * n + 1):
		x = li()
		for j in range(1, i):
			a.append([x[j - 1], i, j])
	a.sort(reverse=True)
	for i in range(len(a)):
		x = a[i][1]
		y = a[i][2]
		if x not in m and y not in m:
			m[x] = y
			m[y] = x
	for i in range(1, 2 * n + 1):
		print(m[i], end=' ')
main()


n = int(input())
a = []
for i in range(2 * n - 1):
	a.append([int(c) for c in input().split()])
c = []
for i in range(len(a)):
	for j in range(len(a[i])):
		c.append([a[i][j], i + 1, j])
c.sort(reverse=True)
used = set()
res = [0] * 2 * n
for cc in c:
	if not cc[1] in used and (not cc[2] in used):
		res[cc[1]] = cc[2] + 1
		res[cc[2]] = cc[1] + 1
		used.add(cc[1])
		used.add(cc[2])
print(' '.join((str(r) for r in res)))


n = int(input())
groups = []
ans = [0] * (2 * n + 1)
for i in range(1, 2 * n):
	a = list(map(int, input().split()))
	for j in range(i):
		groups.append((a[j], j + 1, i + 1))
for i in sorted(groups)[::-1]:
	if not ans[i[1]] and (not ans[i[2]]):
		(ans[i[1]], ans[i[2]]) = (i[2], i[1])
print(' '.join(map(str, ans[1:])))


IL = lambda : list(map(int, input().split()))
n = int(input())
p = n * 2
M = [IL() for i in range(p - 1)]
TC = [(v, i + 1, j) for (i, r) in enumerate(M) for (j, v) in enumerate(r)]
TC.sort(reverse=True)
TM = [0] * p
for (_, i, j) in TC:
	if TM[i] == TM[j] == 0:
		TM[i] = j + 1
		TM[j] = i + 1
print(*TM)


def main():
	n = int(input())
	(res, l, avail) = ([0] * (n * 2), [], [True] * (n * 2))
	for i in range(1, n * 2):
		for (j, x) in enumerate(map(int, input().split())):
			l.append((x, j, i))
	l.sort(reverse=True)
	for (_, i, j) in l:
		if avail[i] and avail[j]:
			(res[i], res[j]) = (j + 1, i + 1)
			avail[i] = avail[j] = False
	print(*res)
main()


def getKey(item):
	return item[2]
n = int(input())
li = []
for _ in range(n * 2 - 1):
	li.append([int(x) for x in input().split()])
ans = [0] * (2 * n + 5)
dict = []
for i in range(2 * n - 2, -1, -1):
	for j in range(0, i + 1):
		dict.append([i + 2, j + 1, li[i][j]])
dict = sorted(dict, key=getKey, reverse=True)
for i in dict:
	if ans[i[0]] == 0 and ans[i[1]] == 0:
		ans[i[0]] = i[1]
		ans[i[1]] = i[0]
print(' '.join(map(str, ans[1:2 * n + 1])))


n = int(input())
arr = []
ans = [0] * (2 * n + 1)
vis = [0] * (2 * n + 1)
for i in range(2, 2 * n + 1):
	temp = list(map(int, input().split()))
	for j in range(1, i):
		arr.append([temp[j - 1], i, j])
arr.sort(reverse=True)
for i in arr:
	if vis[i[1]] or vis[i[2]]:
		continue
	ans[i[1]] = i[2]
	ans[i[2]] = i[1]
	vis[i[1]] = 1
	vis[i[2]] = 1
print(*ans[1:])


n = int(input())
teams = []
for i in range(2, 2 * n + 1):
	w = list(map(int, input().split()))
	for j in range(len(w)):
		teams.append([w[j], i, j + 1])
teams = list(reversed(sorted(teams)))
done = set()
ans = [0] * 2 * n
for i in range(len(teams)):
	if teams[i][1] not in done and teams[i][2] not in done:
		done.add(teams[i][1])
		done.add(teams[i][2])
		ans[teams[i][1] - 1] = teams[i][2]
		ans[teams[i][2] - 1] = teams[i][1]
print(' '.join(list(map(str, ans))))


def aaa():
	n = int(input())
	n *= 2
	a = [[0, 0, 0]] * (n * (n + 1) // 2)
	b = [[]] * n
	used = [-1] * (n + 1)
	for i in range(1, n):
		b[i] = list(map(int, input().split()))
	k = 0
	for i in range(1, n):
		for j in range(i):
			a[k] = [b[i][j], i, j]
			k += 1
	a.sort(reverse=1)
	k = n - 1
	for i in range(k * (k + 1) // 2):
		if used[a[i][1]] == -1 and used[a[i][2]] == -1:
			used[a[i][1]] = a[i][2]
			used[a[i][2]] = a[i][1]
	for i in range(n):
		print(used[i] + 1, end=' ')
aaa()


from sys import stdin
live = True
if not live:
	stdin = open('data.in', 'r')
numbers = []
n = int(stdin.readline().strip())
for i in range(2, 2 * n + 1):
	line = list(map(int, stdin.readline().strip().split()))
	it = 1
	for j in line:
		numbers.append((j, i, it))
		it += 1
teams = 0
pairs = [0] * (2 * n + 1)
numbers = sorted(numbers, key=lambda tup: tup[0], reverse=True)
for (m, i, j) in numbers:
	if teams == n:
		break
	if not pairs[i] and (not pairs[j]):
		pairs[i] = j
		pairs[j] = i
		teams += 1
print(' '.join(list(map(str, pairs[1:]))))
if not live:
	stdin.close()


n = int(input())
ans = {}
arr = []
for con in range(1, 2 * n):
	str = [int(i) for i in input().split(' ')]
	arr.extend([(str[i], i, con) for i in range(len(str))])
arr.sort()
arr.reverse()
for (s, a, b) in arr:
	if a in ans.keys() or b in ans.keys():
		continue
	ans[a] = b + 1
	ans[b] = a + 1
for i in range(2 * n):
	print(ans[i], end=' ')


n = int(input())
d = dict()
for i in range(2, 2 * n + 1):
	l = list(map(int, input().split()))
	for j in range(1, i):
		d[l[j - 1]] = (i, j)
f = [0 for i in range(0, 2 * n + 1)]
for i in reversed(sorted(d.keys())):
	if f[d[i][0]] == 0 and f[d[i][1]] == 0:
		f[d[i][0]] = d[i][1]
		f[d[i][1]] = d[i][0]
for i in range(1, 2 * n + 1):
	print(f[i], end=' ')


from sys import stdin
n = int(stdin.readline())
c = 0
poss = []
for i in range(2 * n - 1):
	c += 1
	ppl = map(int, stdin.readline().split())
	for (j, p) in enumerate(ppl):
		poss.append((c, j, p))
taken = set()
poss = sorted(poss, reverse=True, key=lambda x: x[2])
answer = [-1 for i in range(n * 2)]
for p in poss:
	if p[0] not in taken and p[1] not in taken:
		answer[p[0]] = str(p[1] + 1)
		answer[p[1]] = str(p[0] + 1)
		taken.add(p[0])
		taken.add(p[1])
print(' '.join(answer))


n = int(input())
m = list()
ans = [-1] * 2 * n
for i in range(1, 2 * n):
	m += map(lambda t: (i, int(t[0]), int(t[1])), enumerate(input().split()))
m = sorted(m, key=lambda t: t[2], reverse=True)
for (i, j, _) in m:
	if ans[i] == -1 and ans[j] == -1:
		ans[i] = j + 1
		ans[j] = i + 1
print(' '.join(map(str, ans)))


def mergeSort(arr, l, r, merge_arr):
	if l < r:
		mid = int(l + r) // 2
		mergeSort(arr, l, mid, merge_arr)
		mergeSort(arr, mid + 1, r, merge_arr)
		merge(arr, l, mid, r, merge_arr)

def merge(source, left, mid, right, merge_arr):
	l = left
	r = mid + 1
	for i in range(left, right + 1, 1):
		if source[l][0] <= source[r][0]:
			merge_arr[i] = source[l]
			l = l + 1
			if l == mid + 1:
				i = i + 1
				for j in range(r, right + 1, 1):
					merge_arr[i] = source[j]
					i = i + 1
				break
		else:
			merge_arr[i] = source[r]
			r = r + 1
			if r == right + 1:
				i = i + 1
				for j in range(l, mid + 1, 1):
					merge_arr[i] = source[j]
					i = i + 1
				break
	for i in range(left, right + 1, 1):
		source[i] = merge_arr[i]
a = []
n = int(input())
for i in range(2 * n - 1):
	acopy = input().split()
	for j in range(i + 1):
		a.append([int(acopy[j]), i + 1, j])
merge_arr = [[0, 0, 0] for i in range(len(a))]
answer = [0 for i in range(2 * n)]
players = [False for i in range(2 * n)]
a.sort()
for i in range(len(a) - 1, -1, -1):
	if players[a[i][1]] == False and players[a[i][2]] == False:
		answer[a[i][1]] = a[i][2] + 1
		answer[a[i][2]] = a[i][1] + 1
		players[a[i][1]] = True
		players[a[i][2]] = True
for i in range(len(answer)):
	print(answer[i], end=' ')


n = int(input())
vals = list()
for i in range(2 * n - 1):
	arr = list(map(int, input().split()))
	for (idx, v) in enumerate(arr):
		vals.append((v, idx + 1, i + 2))
vals.sort(key=lambda x: x[0], reverse=True)
map = dict()
for (a, b, c) in vals:
	if b not in map and c not in map:
		map[b] = c
		map[c] = b
print(*[map[x] for x in range(1, n * 2 + 1)])


n = int(input())
m = []
for i in range(2 * n - 1):
	w = list(map(int, input().split()))
	for j in range(len(w)):
		m.append([w[j], i + 1, j])
m = sorted(m)
e = [-1] * (2 * n + 1)
s = 0
while s < 2 * n:
	if e[m[len(m) - 1][1]] == e[m[len(m) - 1][2]] == -1:
		e[m[len(m) - 1][1]] = m[len(m) - 1][2]
		e[m[len(m) - 1][2]] = m[len(m) - 1][1]
		s += 2
	m.pop()
for i in range(2 * n):
	print(e[i] + 1, end=' ')


n = int(input())
l = []
for i in range(n * 2 - 1):
	l.append([int(x) for x in input().split()])
tm = [0] * (n * 2)
for i in range(n):
	ms = [max(r) for r in l]
	m = max(ms)
	i = ms.index(m)
	j = l[i].index(m)
	l[i] = l[j - 1 if j else i] = [0]
	for k in range(n * 2 - 1):
		if i + 1 < len(l[k]):
			l[k][i + 1] = 0
		if j < len(l[k]):
			l[k][j] = 0
	i += 1
	tm[i] = j + 1
	tm[j] = i + 1
print(' '.join((str(x) for x in tm)))


n = int(input())
B = []
ans = [-1] * (2 * n)
used = [0] * (2 * n)
for i in range(1, 2 * n):
	A = list(map(int, input().split()))
	for j in range(i):
		B.append((A[j], i, j))
B.sort(reverse=True)
for (gg, i, j) in B:
	if used[i] == used[j] == 0:
		ans[i] = j + 1
		ans[j] = i + 1
		used[i] = 1
		used[j] = 1
print(*ans)


def main():
	n = int(input()) * 2
	res = [0] * n
	for (_, i, j) in sorted(((int(x), j, i) for i in range(1, n) for (j, x) in enumerate(input().split())), reverse=True):
		if res[i] or res[j]:
			continue
		(res[i], res[j]) = (j + 1, i + 1)
	print(' '.join(map(str, res)))
main()


n = int(input())
a = []
team = [None] * (n + n)
for i in range(1, n + n):
	for (j, v) in enumerate(map(int, input().split())):
		a.append((v, i, j))
a.sort(reverse=True)
for (_, i, j) in a:
	if team[i] is None and team[j] is None:
		team[i] = j + 1
		team[j] = i + 1
print(' '.join((str(i) for i in team)))


import heapq as heap
from sys import stdin, stdout
input = stdin.readline
n = int(input())
h = []
free = [True for _ in range(2 * n)]
for i in range(2 * n - 1):
	for (j, el) in enumerate(map(int, input().split())):
		heap.heappush(h, (-el, (i + 1, j)))
ans = [0] * 2 * n
while len(h):
	(_, v) = heap.heappop(h)
	(i, j) = v
	if free[i] and free[j]:
		ans[i] = str(j + 1)
		ans[j] = str(i + 1)
		free[i] = False
		free[j] = False
stdout.write(' '.join(ans))


import heapq
n = int(input()) * 2
ans = [-1] * (n + 1)
h = []
for i in range(2, n + 1):
	j = 1
	for e in input().split():
		x = int(e)
		heapq.heappush(h, [-x, i, j])
		j += 1
i = 1
while True:
	cur = heapq.heappop(h)
	if ans[cur[1]] == -1 and ans[cur[2]] == -1:
		ans[cur[1]] = cur[2]
		ans[cur[2]] = cur[1]
	while ans[i] != -1 and i < n:
		i += 1
	if i == n:
		break
print(*ans[1:])


n = int(input())
strenghts = []
s_taken = ['0'] * (2 * n + 1)
for i in range(1, 2 * n):
	tmp = [int(x) for x in input().split(' ')]
	for j in range(i):
		strenghts.append((j + 1, i + 1, tmp[j]))
teams = 0
strenghts.sort(key=lambda x: x[2])
while True:
	if teams == n:
		break
	team = strenghts.pop()
	if s_taken[team[0]] == '0' and s_taken[team[1]] == '0':
		s_taken[team[0]] = str(team[1])
		s_taken[team[1]] = str(team[0])
		teams += 1
s_taken.pop(0)
print(' '.join(s_taken))


from collections import defaultdict
n = int(input())
d = defaultdict()
t = 0
b = []
c = []
aa = [0] * (2 * n + 1)
while t < 2 * n - 1:
	a = [int(x) for x in input().split()]
	for i in range(len(a)):
		d[a[i]] = [t + 2, i + 1]
	t = t + 1
l = sorted(d.items())
i = len(l) - 1
k = 0
while i >= 0:
	if aa[l[i][1][0]] == 0 and aa[l[i][1][1]] == 0:
		aa[l[i][1][0]] = l[i][1][1]
		aa[l[i][1][1]] = l[i][1][0]
		k = k + 2
		if k == 2 * n:
			break
	i = i - 1
for i in range(1, 2 * n + 1):
	print(aa[i], end=' ')


n = int(input())
table = []
for i in range(2 * n - 1):
	li = list(map(int, input().split()))
	for j in range(i + 1):
		table.append([li[j], i + 2, j + 1])
table.sort(key=lambda x: x[0], reverse=True)
res = [0 for _ in range(2 * n)]
entry = 0
idx = 0
while entry != n:
	t = table[idx]
	(t1, t2) = (t[1] - 1, t[2] - 1)
	if res[t1] == 0 and res[t2] == 0:
		res[t1] = t2 + 1
		res[t2] = t1 + 1
		entry += 1
	idx += 1
print(' '.join(map(str, res)))


import sys
n = int(input())
stud = []
for i in range(1, 2 * n):
	lst = [int(x) for x in input().split()]
	for j in range(len(lst)):
		stud += [(lst[j], j, i)]
stud.sort(reverse=True)
ans = [-1 for x in range(2 * n)]
for item in stud:
	first = item[1]
	second = item[2]
	if ans[first] == ans[second] == -1:
		ans[first] = second
		ans[second] = first
for x in ans:
	print(x + 1, end=' ')
print()


n = int(input())
strs = [list(map(int, input().split())) for _ in range(2 * n - 1)]
entries = sorted(((v, i, j) for (i, row) in enumerate(strs) for (j, v) in enumerate(row)), reverse=True)
ans = [-1] * (2 * n)
for (v, i, j) in entries:
	i += 1
	if ans[i] != -1 or ans[j] != -1:
		continue
	ans[i] = j + 1
	ans[j] = i + 1
print(' '.join(map(str, ans)))


n = int(input())
p = [-1] * 2 * n
k = []
for i in range(2 * n - 1):
	a = list(map(int, input().split()))
	for t in range(i + 1):
		k.append([a[t], i + 1, t])
k.sort()
for i in range(len(k) - 1, -1, -1):
	if p[k[i][1]] == -1 and p[k[i][2]] == -1:
		p[k[i][1]] = k[i][2] + 1
		p[k[i][2]] = k[i][1] + 1
print(*p)


n = int(input()) * 2
v = []
for i in range(1, n):
	a = [int(str) for str in input().split(' ')]
	for j in range(0, i):
		v.append([a[j], i, j])
v.sort(reverse=True)
r = [-1] * n
for i in range(len(v)):
	if r[v[i][1]] == -1 and r[v[i][2]] == -1:
		r[v[i][1]] = v[i][2]
		r[v[i][2]] = v[i][1]
for i in range(n):
	print(str(r[i] + 1) + ' ', end='')


from itertools import permutations

def main():
	n = int(input())
	a = [[int(j) for j in input().split()] + [0] for i in range(2 * n - 1)]
	a = [[0]] + a
	(l, done) = ([], set())
	for (i, ii) in enumerate(a):
		for (j, jj) in enumerate(ii):
			l.append((jj, i, j))
	(l, ans) = (sorted(l, reverse=True), {})
	for i in l:
		if len(done) == 2 * n:
			break
		if i[1] not in done and i[2] not in done:
			done.add(i[1])
			done.add(i[2])
			ans[i[1] + 1] = i[2] + 1
			ans[i[2] + 1] = i[1] + 1
	for i in range(1, 2 * n + 1):
		print(ans[i], end=' ')
main()


n = int(input())
ans = [0] * (n * 2 + 1)
used = [False] * (n * 2 + 1)
arr = []
for i in range(2, n * 2 + 1):
	qwe = [0] + [int(x) for x in input().split()]
	for j in range(1, i):
		arr.append((qwe[j], i, j))
arr.sort(reverse=True)
for x in arr:
	if not used[x[1]] and (not used[x[2]]):
		used[x[1]] = used[x[2]] = True
		ans[x[1]] = x[2]
		ans[x[2]] = x[1]
print(*ans[1:])