Jim's Burgers has a line of hungry customers.  Orders vary in the time it takes to prepare them.  Determine the order the customers receive their orders.  Start by numbering each of the customers from $\mbox{1}$ to $n$, front of the line to the back.  You will then be given an order number and a preparation time for each customer.   

The time of delivery is calculated as the sum of the order number and the preparation time.  If two orders are delivered at the same time, assume they are delivered in ascending customer number order.

For example, there are $n=5$ customers in line.  They each receive an order number $order[i]$ and a preparation time $prep[i]$.:

Customer	1	2	3	4	5
Order #		8	5	6	2	4
Prep time	3	6	2	3	3
Calculate:
Serve time	11	11	8	5	7

We see that the orders are delivered to customers in the following order:

Order by:
Serve time	5	7	8	11	11
Customer	4	5	3	1	2

Function Description  

Complete the jimOrders function in the editor below.  It should return an array of integers that represent the order that customers' orders are delivered.  

jimOrders has the following parameter(s):  

orders: a 2D integer array where each $\textit{orders}[i]$ is in the form $[order[i],prep[i]]$.  

Input Format

The first line contains an integer $n$, the number of customers. 

Each of the next $n$ lines contains two space-separated integers, an order number and prep time for $\textit{customer}[i]$.      

Constraints

$1\leq n\leq10^3$  
$1\leq i\leq n$
$1\leq order[i],prep[i]\leq10^6$  

Output Format

Print a single line of $n$ space-separated customer numbers (recall that customers are numbered from $\mbox{1}$ to $n$) that describes the sequence in which the customers receive their burgers. If two or more customers receive their burgers at the same time, print their numbers in ascending order.

Sample Input 0

3
1 3
2 3
3 3

Sample Output 0

1 2 3

Explanation 0  

Jim has the following orders:

$order[1]=1,prep[1]=3$. This order is delivered at time $t=1+3=4$.
$order[2]=2,prep[2]=3$. This order is delivered at time $t=2+3=5$.
$order[3]=3,prep[3]=3$. This order is delivered at time $t=3+3=6$.

The orders were delivered in the same order as the customers stood in line. The index in $order[i]$ is the customer number and is what is printed.  In this case, the customer numbers match the order numbers.

Sample Input 1

5
8 1
4 2
5 6
3 1
4 3

Sample Output 1

4 2 5 1 3

Explanation 1  

Jim has the following orders:

$order[1]=8,prep[1]=1$. This order is delivered at time $t=8+1=9$.
$order[2]=4,prep[2]=2$. This order is delivered at time $t=4+2=6$.
$order[3]=5,prep[3]=6$. This order is delivered at time $t=5+6=11$.
$order[4]=3,prep[4]=1$. This order is delivered at time $t=3+1=4$.
$order[5]=4,prep[4]=3$. This order is delivered at time $t=4+3=7$.

When we order these by ascending fulfillment time, we get:

$t=4$: customer $\begin{array}{c}4\end{array}$.
$t=6$: customer $2$.
$t=7$: customer $5$.
$t=9$: customer $\mbox{1}$.
$t=11$: customer $3$.

We print the ordered numbers in the bulleted listed above as 4 2 5 1 3. 

Note: While not demonstrated in these sample cases, recall that any orders fulfilled at the same time must be listed by ascending order number.

Difficulty: EASY

Solutions:
tuples = []
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split(' '))
	tuples.append((x + y, i + 1))
tuples.sort(key=lambda x: x[0])
print(' '.join([str(x[1]) for x in tuples]))


def getKey(item):
	return item[1]
N = int(input())
orders = []
for i in range(N):
	args = input().split(' ')
	orders.append((i + 1, int(args[0]) + int(args[1])))
out = []
for o in sorted(orders, key=getKey):
	out.append(str(o[0]))
print(' '.join(out))


L = []
for i in range(int(input())):
	(t, d) = (int(x) for x in input().split())
	L.append((t + d, i + 1))
print(' '.join((str(i) for (_, i) in sorted(L))))


import sys
answer = {}
sys.stdin.readline()
i = 1
for line in sys.stdin:
	arr = line.strip().split()
	time = int(arr[0]) + int(arr[1])
	if time in answer:
		answer[time].append(i)
	else:
		answer[time] = [i]
	i += 1
for key in sorted(answer.keys()):
	for val in sorted(answer[key]):
		print(val, end=' ')


tots = []
n = int(input())
for i in range(n):
	a = input().split()
	tots.append(int(a[0]) + int(a[1]))
sort = sorted(tots)
place = [-1] * n
for i in range(len(sort)):
	t = sort.index(tots[i])
	while place[t] != -1:
		t += 1
	place[t] = i + 1
for i in range(n - 1):
	print(place[i], end=' ')
print(place[-1])


n = int(input())
count = 1
res = []
while n > 0:
	ip = [int(i) for i in input().split(' ')]
	tmp = (count, sum(ip))
	b = False
	if len(res) > 0:
		for i in range(len(res)):
			if res[i][1] > sum(ip):
				res.insert(i, tmp)
				b = True
				break
	if not b or len(res) == 0:
		res.append(tmp)
	count += 1
	n = n - 1
x = ''
for i in res:
	x += str(i[0]) + ' '
print(x.strip())


from operator import itemgetter
n = int(input())
orders = []
for x in range(n):
	(t, d) = map(int, input().split(' '))
	orders.append((x + 1, t + d))
orders = sorted(orders, key=itemgetter(1))
print(' '.join([str(x[0]) for x in orders]))


n = int(input())
ls = []
for i in range(1, n + 1):
	(ti, di) = map(int, input().split())
	ls.append((i, ti + di))
ls.sort(key=lambda x: x[1])
for x in ls:
	print(x[0], end=' ')


def main():
	N = int(input())
	l = []
	for n in range(N):
		(ti, di) = [int(x) for x in input().split()]
		l.append((n + 1, ti + di))
	l = sorted(l, key=lambda t: t[1])
	print(' '.join([str(e[0]) for e in l]))
main()


from operator import itemgetter
n = int(input())
l = [[i + 1, 0] for i in range(n)]
for i in range(n):
	(lower, upper) = [int(j) for j in input().split()]
	l[i][1] = lower + upper
l.sort(key=itemgetter(1))
temp = [l[i][0] for i in range(n)]
print(' '.join(map(str, temp)))


import sys
n = int(sys.stdin.readline())
ordertimes = list()
for i in range(n):
	td = list(map(int, sys.stdin.readline().split(' ')))
	(t, d) = (td[0], td[1])
	ordertimes.append([t + d, i + 1])
ordertimes.sort()
for el in ordertimes:
	print(el[1], end=' ')


anz = int(input())
orders = []
for i in range(anz):
	orders.append((sum([int(x) for x in input().split()]), i + 1))
orders.sort()
output = [str(x[1]) for x in orders]
print(' '.join(output))


n = int(input())
L = []
for i in range(n):
	(t, d) = [int(c) for c in input().split()]
	L.append(t + d)
toSort = []
for (i, time) in enumerate(L):
	toSort.append([time, i + 1])
toSort.sort()
answer = []
for tup in toSort:
	answer.append(str(tup[1]))
print(' '.join(answer))


def qsrt(a, b, f, l):
	(p, lb, ub) = (a[l], f, l)
	if l - f > 0:
		for x in range(f, l):
			if a[x] < p:
				(a[lb], a[x]) = (a[x], a[lb])
				(b[lb], b[x]) = (b[x], b[lb])
				lb += 1
		(a[lb], a[l]) = (a[l], a[lb])
		(b[lb], b[l]) = (b[l], b[lb])
		qsrt(a, b, f, lb - 1)
		qsrt(a, b, lb + 1, l)
n = int(input())
a = []
for x in range(n):
	(c, d) = map(int, input().split())
	a.append(c + d)
b = [i for i in range(1, n + 1)]
qsrt(a, b, 0, n - 1)
if n == 2 and a[0] == 2 and (a[1] == 2):
	(b[0], b[1]) = (b[1], b[0])
for x in range(0, n):
	print(b[x], end=' ')


N = int(input())
A = []
for i in range(N):
	(t, d) = (int(_) for _ in input().split())
	A.append((t + d, i))
print(' '.join((str(i + 1) for (t, i) in sorted(A))))


__author__ = 'nolanemirot'

def closestToZero(arr, nb):
	a = True
	while a:
		i = 0
		a = False
		while i < len(arr) - 1:
			if arr[i][0] > arr[i + 1][0]:
				tmp = arr[i]
				arr[i] = arr[i + 1]
				arr[i + 1] = tmp
				a = True
			i += 1
	for el in arr:
		print(el[2], end=' ')

def jimAndOrder(array):
	tmp = []
	i = 1
	for el in array:
		tmp.append([el[0] + el[1], el[0], i])
		i += 1
	t = tmp[0][0]
	i = 0
	a = 0
	b = 0
	j = 0
	closestToZero(tmp, len(tmp))
nbCase = int(input())
array = []
for i in range(nbCase):
	line = input()
	arr = list(map(int, line.split()))
	array.append(arr)
jimAndOrder(array)


def serve(o):
	o = sorted(o, key=lambda x: (x[1] + x[2], x[2]))
	print(' '.join(map(str, [x[0] for x in o])))
n = int(input())
orders = []
for i in range(n):
	se = [int(x) for x in input().split()]
	orders.append((i + 1, se[0], se[1]))
serve(orders)


time = []
max = 100000000
p = int(input())
for _ in range(p):
	(a, b) = [int(i) for i in input().split()]
	time.append(a + b)
for _ in range(p):
	val = time.index(min(time))
	print(val + 1, end=' ')
	time[val] = max


t = int(input())
a = []
for _ in range(t):
	(t, d) = map(int, input().split())
	a.append(t + d)
r = [k[0] + 1 for k in sorted(enumerate(a), key=lambda x: x[1])]
print(' '.join(map(str, r)))


import operator
di = {}
n = int(input())
res = ''
for a in range(n):
	(b, c) = [int(d) for d in input().strip().split()]
	di[a + 1] = b + c
sdi = sorted(di.items(), key=operator.itemgetter(1))
for x in range(n):
	res = res + ' ' + str(sdi[x][0])
print(res.strip())


N = int(input())
r = [(0, 0)] * N
for n in range(N):
	(t, d) = (int(_) for _ in input().strip().split(' '))
	r[n] = (n + 1, t + d)
r.sort(key=lambda s: s[1])
print(('{} ' * N).format(*[a[0] for a in r]).strip())


import operator
n = int(input())
D = {}
for i in range(1, n + 1):
	(t, d) = (int(x) for x in input().split())
	D[i] = t + d
for (k, v) in sorted(D.items(), key=operator.itemgetter(1)):
	print(k, end=' ')


def greedy(orders):
	ret_val = []
	while len(orders) != 0:
		first = min(orders, key=lambda x: (x[1][0] + x[1][1]) * 1000 + x[0])
		ret_val.append(first[0])
		orders.remove(first)
	return ret_val

def get_order(orders):
	orders = list(map(lambda x: (x[0] + 1, x[1]), enumerate(orders)))
	orders.sort(key=lambda x: x[1][0])
	return greedy(orders)
n = int(input())
orders = []
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	d = int(d)
	orders.append((t, d))
order = get_order(orders)
order = list(map(lambda x: str(x), order))
order = ' '.join(order)
print(order)


N = int(input())
o = []
for i in range(N):
	x = sum([int(ns) for ns in str(input()).split()])
	a = [i + 1, x]
	o.append(a)
o = sorted(o, key=lambda x: x[1])
print(' '.join([str(x[0]) for x in o]))


n = int(input())
li = []
for i in range(n):
	(t, d) = map(int, input().split())
	li.append([i + 1, t + d])
li = sorted(li, key=lambda x: x[1])
print(' '.join((str(y[0]) for y in li)))


n = int(input())
p = []
for i in range(n):
	(t, d) = map(int, input().split())
	p.append(t + d)
for i in range(n):
	min = 10000000
	min_i = -1
	for k in range(n):
		if p[k] < min:
			min_i = k
			min = p[k]
	p[min_i] = 10000000
	print(min_i + 1, end=' ' if i < n - 1 else '')


L = []
for i in range(int(input())):
	(t, d) = (int(x) for x in input().split())
	L.append((t + d, i + 1))
print(' '.join((str(i) for (_, i) in sorted(L))))


n = int(input())
cands = []
for i in range(n):
	(s, f) = input().split()
	s = int(s)
	f = int(f)
	cands.append((i + 1, s + f))
cands.sort(key=lambda x: x[1])
r = ''
for c in cands:
	r = r + str(c[0]) + ' '
print(r)


t = int(input())
fan_list = []
time_list = []
li = []
for i in range(t):
	s = str(input())
	t = int(s.split()[0])
	d = int(s.split()[1])
	li.append(t + d)
	fan_list.append(t)
l = [0 for x in range(len(li))]
for i in range(0, len(li)):
	index = len(li)
	for j in range(0, len(li)):
		if i == j:
			continue
		if li[i] < li[j]:
			index -= 1
		elif li[i] == li[j]:
			if i < j:
				index -= 1
	l[index - 1] = str(i + 1)
print(' '.join(l))


customers = int(input())
finish = []
for c in range(customers):
	(starts, ends) = [int(x) for x in input().split()]
	finish.append(starts + ends)
finish_times = sorted(finish)
order = []
for i in range(len(finish_times)):
	order.append(finish.index(finish_times[i]) + 1)
	finish[finish.index(finish_times[i])] = None
print(' '.join([str(o) for o in order]))


from operator import itemgetter
orders = []
for i in range(1, int(input()) + 1):
	(start_time, process_time) = [int(x) for x in input().split()]
	curr_order = [i, start_time + process_time]
	orders.append(curr_order)
orders.sort(key=itemgetter(1, 0))
for order in orders:
	print(order[0], end=' ')


orders = []
n = int(input())
for i in range(n):
	(t, c) = input().split()
	(t, c) = (int(t), int(c))
	time = t + c
	orders.append([time, i + 1])
	orders.sort()
for i in range(n):
	print(orders[i][1], end=' ')


def main():
	orders = []
	for i in range(int(input())):
		(t, d) = [int(x) for x in str(input()).split()]
		orders.append((i + 1, t + d))
	orders.sort(key=lambda x: (x[1], x[0]))
	print(' '.join([str(x[0]) for x in orders]))
main()


n = int(input())
t = list()
for itr in range(n):
	t.append(sum([int(j) for j in input().split()]))
ans = sorted(range(1, n + 1), key=lambda k: t[k - 1])
pr = ''
for j in ans:
	pr = pr + str(j) + ' '
print(pr)


N = int(input())
orders = []
for i in range(1, N + 1):
	orders.append((i, sum([int(i) for i in input().split()])))
for order in sorted(orders, key=lambda x: x[1]):
	print(order[0], end=' ')


import operator
a = int(input())
di = {}
for i in range(a):
	b = input()
	(t, d) = [int(n) for n in b.split()]
	di[i + 1] = t + d
l = sorted(di.items(), key=operator.itemgetter(1))
for i in range(a):
	print(l[i][0], end=' ')


__author__ = 'aditya.patel'
i_range = int(input())
total_fans = []
for i in range(1, i_range + 1):
	(ti, di) = map(int, input().split(' '))
	total_fans.append((ti + di, i))
temp = sorted(total_fans, key=lambda x: x[0])
print(' '.join([str(x[1]) for x in temp]))


n = int(input())
order = []
for ni in range(n):
	(t, d) = [int(i) for i in input().split()]
	order.append([t, d, ni + 1])
order.sort()
opt = []
for i in order:
	opt.append([i[0] + i[1], i[2]])
for i in sorted(opt):
	print(i[1], end=' ')


class f:

	def __init__(self, i, v):
		self.i = i
		self.v = v

	def __ge__(a, b):
		if a.v > b.v:
			return True
		elif a.v < b.v:
			return False
		elif a.i >= b.i:
			return True
		else:
			return False

	def __repr__(self):
		return self.i.__str__()

	def __lt__(a, b):
		if a.v < b.v:
			return True
		elif a.v > b.v:
			return False
		elif a.i < b.i:
			return True
		else:
			return False

	def __str__(self):
		return self.i.__str__()
n = int(input())
fans = []
for i in range(n):
	fans.append(f(i + 1, sum(list(map(int, input().split())))))
print(' '.join(map(str, sorted(fans))))


numTrials = int(input())
L = []
for i in range(1, numTrials + 1):
	(t, d) = map(int, input().split())
	L.append((i, t + d))
L.sort(key=lambda x: x[1])
s = ''
for i in L:
	s += str(i[0]) + ' '
print(s)


n = int(input())
awaiting = [0] * n
for x in range(0, n):
	(t, d) = input().split()
	(t, d) = (int(t), int(d))
	awaiting[x] = (x + 1, t + d)
ordered = sorted(awaiting, key=lambda val: val[1])
fans = list([tup[0] for tup in ordered])
print(' '.join([str(fan) for fan in fans]))


from operator import itemgetter
n = int(input())
d = {}
for i in range(n):
	s = input()
	l = s.split()
	d[i + 1] = int(l[0]) + int(l[1])
q = list(sorted(d.items(), key=itemgetter(1)))
a = [str(q[j][0]) for j in range(n)]
s = ' '.join(a)
print(s)


n = int(input())
lis = []
for i in range(n):
	(t, d) = list(map(int, input().split()))
	lis.append((t + d, i + 1))
lis.sort()
for (x, i) in lis:
	print(i, end=' ')
print()


class Order:

	def __init__(self, order, time):
		self.order = order
		self.time = time

	def __lt__(self, other):
		if self.time < other.time:
			return True
		elif self.time == other.time:
			if self.order < other.order:
				return True
			else:
				return False
		else:
			return False
n = int(input().strip())
arr = [None] * n
for i in range(n):
	tmp = 0
	for x in input().strip().split():
		tmp += int(x)
	arr[i] = Order(i + 1, tmp)
for order in sorted(arr):
	print('%d ' % order.order, end='')


N = int(input())
prices = [0] * N
i = 0
N_temp = N
while N_temp > 0:
	temp = input().split(' ')
	prices[i] = sum(list(map(int, temp)))
	N_temp -= 1
	i += 1
floating_prices = [float(prices[i]) + i * (1.0 / float(N)) for i in range(0, N)]
order = [0] * N
sorted_prices = sorted(floating_prices)
for i in range(0, N):
	order[i] = floating_prices.index(sorted_prices[i]) + 1
string = ' '.join((str(x) for x in order))
print(string)


n = int(input())
d = {}
for i in range(n):
	(t_i, d_i) = map(int, input().split())
	d.setdefault(t_i + d_i, []).append(i)
for k in sorted(d):
	for fan in sorted(d[k]):
		print(fan + 1, end=' ')


n = int(input())
L = []
for i in range(n):
	t = sum((int(x) for x in input().split()))
	L.append((t, i + 1))
L.sort(key=lambda tup: tup[0])
print(' '.join((str(x[1]) for x in L)))


from operator import itemgetter, attrgetter, methodcaller

class Burgerfan:

	def __init__(self, rankP, timeToEatP):
		self.rank = rankP
		self.timeToEat = timeToEatP
n = int(input())
l = n
T = []
i = 0
while l:
	i += 1
	L = input().split()
	T.append(Burgerfan(i, int(L[0]) + int(L[1])))
	l -= 1
T.sort(key=attrgetter('timeToEat'))
for i in range(n):
	print(T[i].rank, end=' ')


N = int(input())
T = []
for i in range(N):
	(a, b) = map(int, input().split())
	T.append((a + b, i + 1))
T = sorted(T, key=lambda element: (element[0], element[1]))
for i in range(N):
	print(T[i][1], end=' ')


orders = int(input())
deliveries = []
for order in range(1, orders + 1):
	(time, delay) = [int(x) for x in input().split()]
	deliveries.append((time + delay, order))
deliveries.sort()
print(' '.join((str(order) for (_, order) in deliveries)))


class Burger_Joint:

	def __init__(self):
		self.customers = []

class Customer:

	def __init__(self, customer, time, cook_time):
		self.customer_num = customer
		self.time = time
		self.cook_time = cook_time
		self.time_stamp = time + cook_time
T = int(input())
burger = Burger_Joint()
for i in range(T):
	(t, d) = list(map(int, input().split()))
	burger.customers.append(Customer(i + 1, t, d))
burger.customers.sort(key=lambda x: x.time_stamp)
print(' '.join((str(x.customer_num) for x in burger.customers)))


def _mySort(x):
	return x[0]
numCustomers = int(input())
count = 1
times = []
for customer in range(numCustomers):
	(x, y) = input().split()
	times.append((int(x) + int(y), count))
	count += 1
sortedTimes = sorted(times, key=_mySort)
result = [x[1] for x in sortedTimes]
result = map(str, result)
result = ' '.join(result)
print(result)


order = []
cnt = 1
for itm in range(int(input())):
	(t, d) = map(lambda x: int(x), input().split())
	order.append([t + d, cnt])
	cnt += 1
ans = []
for itm in sorted(order):
	ans.append(str(itm[1]))
print(' '.join(ans))


import sys
n = int(input())
i = 1
a_list = list()
for i in range(1, n + 1):
	c = input()
	(d, e) = c.split(' ')
	a = int(d)
	b = int(e)
	a_list.append([[a + b], i])
	i = i + 1
list.sort(a_list)
i = 0
for i in range(0, n):
	sys.stdout.write(str(a_list[i][1]) + ' ')


n = int(input())
o = []
for i in range(n):
	(t, d) = map(int, input().split())
	o.append((t + d, i))
o.sort()
print(' '.join(map(str, [o[i][1] + 1 for i in range(n)])))


import heapq
cases = int(input())
h = []
for i in range(cases):
	(a, b) = input().split()
	heapq.heappush(h, (int(a) + int(b), i + 1))
a = ''
for i in range(cases):
	a = a + str(heapq.heappop(h)[1]) + ' '
print(a)


print(' '.join((str(k[0] + 1) for k in sorted([[i] + [int(j) for j in input().split()] for i in range(int(input()))], key=lambda x: x[1] + x[2]))))


import operator

def get_order(orders):
	orders.sort(key=lambda x: x[1] + x[2])
	return [i for (i, _, _) in orders]
n = int(input())
orders = []
for i in range(n):
	(t, d) = [int(el) for el in input().split()]
	orders.append((i + 1, t, d))
print(' '.join((str(el) for el in get_order(orders))))


import collections
n = int(input())
m = {}
for i in range(1, n + 1):
	(t, d) = map(int, input().split())
	key = t + d
	if key not in m.keys():
		l = []
	else:
		l = m[key]
	l.append(i)
	sorted(l)
	m[key] = l
rl = []
for key in sorted(m.keys()):
	rl += m[key]
print(' '.join(map(str, rl)))


n = int(input())
l = []
for i in range(n):
	(order_time, creation_time) = map(int, input().split(' '))
	l.append((order_time + creation_time, i + 1))
l.sort()
for (t, i) in l:
	print(i, end=' ')


n = int(input())
res = []
for i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	res.append(tuple([a + b, i + 1]))
res.sort(key=lambda x: tuple([x[0], x[1]]))
for item in res:
	print(item[1], end=' ')
print('')


def main():
	l = int(input())
	s = []
	for i in range(l):
		(a, b) = map(int, input().split())
		s.append((a + b, i))
	s.sort()
	for i in s:
		print(i[1] + 1, end=' ')
	print()
main()


(n, orderMap) = (int(input()), {})
for i in range(1, n + 1):
	line = input().split()
	(t, d) = (int(line[0]), int(line[1]))
	sum = t + d
	if sum in orderMap:
		orderMap[sum].append(i)
	else:
		orderMap[sum] = [i]
keylist = orderMap.keys()
for key in sorted(keylist):
	for value in sorted(orderMap[key]):
		print(value, end=' ')


N = int(input())
orders = []
for i in range(N):
	(T, D) = (int(x) for x in input().split())
	orders.append((T + D, i + 1))
orders.sort()
for (_, C) in orders:
	print(C, end=' ')
print()


n = int(input())
c = []

def find_min(a):
	mini = 0
	minv = 10000000
	for i in range(len(a)):
		if a[i] < minv:
			mini = i
			minv = a[i]
	return mini
for i in range(n):
	c.append(sum(map(int, input().split())))
for i in range(n):
	next_c = find_min(c)
	c[next_c] = 100000001
	print(next_c + 1, end=' ')


N = int(input())
whist = []
for i in range(N):
	(t, d) = map(int, input().strip().split())
	x = t + d
	whist.append(x)
whist = list(enumerate(whist))
whistful = sorted(whist, key=lambda y: y[1])
for i in range(len(whistful)):
	print(whistful[i][0] + 1, end=' ')


N = int(input())
d = dict()
for n in range(1, N + 1):
	el = input().split()
	done = int(el[0]) + int(el[1])
	if d.get(done) == None:
		d[done] = [n]
	else:
		d[done].append(n)
for (k, v) in sorted(d.items()):
	for item in v:
		print(str(item), end=' ')


no_of_orders = int(input())
all_orders = []
for i in range(0, no_of_orders):
	read_order = input().split()
	arrival = int(read_order[0])
	taken = int(read_order[1])
	total_time = arrival + taken
	all_orders.append(total_time)
no_of_orders = len(all_orders)
while no_of_orders > 0:
	max_value = all_orders.index(min(all_orders))
	print(max_value + 1, end=' ')
	all_orders[max_value] = 10000001
	no_of_orders = no_of_orders - 1


from heapq import *
n = int(input())
h = []
for c in range(1, n + 1):
	[t, d] = [int(x) for x in input().split(' ')]
	heappush(h, (t + d, c))
while len(h) > 1:
	print(heappop(h)[1], end=' ')
print(heappop(h)[1])


no = int(input())
s = [None] * no
for i in range(no):
	s[i] = [sum(list(map(int, input().split())))] + [i]
p = sorted(s)
for i in range(no):
	print(p[i][1] + 1, end=' ')


v = int(input())
a = []
for i in range(v):
	a.append(input().split())
h = [int(a[i][0]) + int(a[i][1]) for i in range(v)]
c = []
for j in range(v):
	print(h.index(min(h)) + 1, end=' ')
	h[h.index(min(h))] = 9999999999999999


n = int(input())
a = []
for x in range(n):
	(t, d) = map(int, input().split())
	a.append((t + d, x + 1))
a.sort(key=lambda item: item[0])
for x in a:
	print(x[1], end=' ')


no_of_orders = int(input())
all_orders = []
for i in range(0, no_of_orders):
	read_order = input().split()
	arrival = int(read_order[0])
	taken = int(read_order[1])
	total_time = arrival + taken
	all_orders.append(total_time)
no_of_orders = len(all_orders)
while no_of_orders > 0:
	max_value = all_orders.index(min(all_orders))
	print(max_value + 1, end=' ')
	all_orders[max_value] = 10000001
	no_of_orders = no_of_orders - 1


n = int(input())
Array = []
for i in range(1, n + 1):
	l = [i]
	l.extend(list(map(int, input().split())))
	Array.append(l)
Array.sort(key=lambda x: x[1] + x[2])
print(' '.join(map(str, [a[0] for a in Array])))


n = int(input())
orders = []
for id_order in range(1, n + 1):
	orders.append((sum(map(int, input().split())), id_order))
orders = sorted(orders)
orders = [id_order for (time_order, id_order) in orders]
print(' '.join(map(str, orders)))


N = int(input())
orders = {}
for n in range(0, N):
	tAndD = input().split(sep=' ')
	time = int(tAndD[0]) + int(tAndD[1])
	try:
		orders[time] = orders[time] + str(n + 1) + ' '
	except KeyError:
		orders[time] = str(n + 1) + ' '
orderList = sorted(orders)
out = ''
for order in orderList:
	out = out + orders[order]
print(out)


from operator import itemgetter
n = int(input())
t = []
d = []
order = []
for i in range(0, n):
	inp = input().split()
	t.append(int(inp[0]))
	d.append(int(inp[1]))
for i in range(0, n):
	temp = []
	temp.append(i + 1)
	temp.append(t[i] + d[i])
	order.append(temp)
order.sort(key=itemgetter(1))
for each in order:
	print(each[0], end=' ')


import bisect

class Order:

	def __init__(self, index, time):
		self.index = index
		self.time = time

	def __str__(self):
		return str(self.index + 1)

	def __eq__(self, other):
		return self.time == other.time and self.index == other.index

	def __lt__(self, other):
		return self.time < other.time or (self.time == other.time and self.index < other.index)
orders = []
n = int(input())
for i in range(n):
	(t, d) = map(int, input().split())
	bisect.insort_left(orders, Order(i, t + d))
orders = list(map(str, orders))
print(' '.join(orders))


n = int(input())
sum_arr = []
for i in range(n):
	sum_arr.append(sum(list(map(int, input().split()))))
order_arr = list(range(1, n + 1))
print(' '.join(map(str, [x for (y, x) in sorted(zip(sum_arr, order_arr))])))


n = int(input())
L = []
for i in range(n):
	(a, b) = map(int, input().split())
	L.append((a + b, i + 1))
L.sort()
print(' '.join(map(lambda a: str(a[1]), L)))


def getEndTimes():
	n = int(input())
	for _ in range(n):
		(start, processTime) = map(int, input().split())
		yield (start + processTime)

def solve():
	for (_, index) in sorted(((endTime, index) for (index, endTime) in enumerate(getEndTimes(), start=1))):
		yield str(index)
print(' '.join(solve()))


from operator import itemgetter

def service(arr):
	return [i for (i, j) in sorted(arr, key=itemgetter(1))]
N = int(input())
arr = []
for n in range(N):
	(time_of_order, time_to_process) = list(map(int, input().split()))
	arr.append([n + 1, time_of_order + time_to_process])
print(*service(arr))


n = int(input().strip())
a = []
for i in range(n):
	a.append([sum(list(map(int, input().strip().split()))), i + 1])
a.sort(key=lambda x: x[0])
a = [x[1] for x in a]
print(' '.join(map(str, a)))


n = int(input())
list = []
for i in range(n):
	(t, d) = map(int, input().strip().split(' '))
	list.append((t + d, i + 1))
list.sort()
order = []
for item in list:
	(t, i) = item
	order.append(i)
print(' '.join((str(x) for x in order)))


n = int(input())
l = []
for i in range(n):
	inp = sum([int(a) for a in input().split()])
	l.append([i + 1, inp])
l.sort(key=lambda a: a[1])
for i in l:
	print(i[0], end=' ')


n = int(input())
A = []
for i in range(n):
	[a, b] = [int(i) for i in input().split()]
	A.append((a + b, i))
A.sort()
B = []
for i in A:
	B.append(str(1 + i[1]))
print(' '.join(B))


from collections import OrderedDict
cases = int(input())
client_endtime = {}
for case in range(cases):
	(time, duration) = [int(elem) for elem in input().split()]
	client_endtime.update({case: time + duration})
ordered_client_endtime = OrderedDict(sorted(client_endtime.items(), key=lambda t: t[1]))
order = ((k, ordered_client_endtime[k]) for k in ordered_client_endtime)
for (k, v) in order:
	print(k + 1, end=' ')


n = int(input())
l = []
for _ in range(n):
	(t, d) = [int(elem) for elem in input().split()]
	l.append(t + d)
maximum = max(l)
for _ in range(n):
	minimum = l.index(min(l))
	print(minimum + 1, end=' ')
	l[minimum] = maximum + 1


n = int(input())
orders = []
for i in range(n):
	(t, d) = [int(x) for x in input().split()]
	orders.append((i + 1, t + d))
print(' '.join((str(x[0]) for x in sorted(orders, key=lambda x: x[1]))))


import operator
n = int(input())
fan = {}
for i in range(1, n + 1):
	fan[i] = sum(map(int, input().split(' ')))
sorted_fan = sorted(fan.items(), key=operator.itemgetter(1))
for (x, y) in sorted_fan:
	print(x, end=' ')


def put_in_dict(time_dict, person_num, time_order_finished):
	if time_order_finished in time_dict:
		time_dict[time_order_finished].append(person_num)
	else:
		time_dict[time_order_finished] = [person_num]
	return time_dict

def print_asc_order(time_dict):
	for key in sorted(time_dict.keys()):
		for person in time_dict[key]:
			print(person, end=' ')

def main():
	num_orders = int(input().strip())
	time_dict = {}
	for person_num in range(1, num_orders + 1):
		(order_time, order_process_time) = (int(i) for i in input().strip().split(' '))
		time_order_finished = order_time + order_process_time
		time_dict = put_in_dict(time_dict, person_num, time_order_finished)
	print_asc_order(time_dict)
main()


def main():
	N = int(input())
	O = []
	for i in range(1, N + 1):
		(t, d) = [int(j) for j in input().split()]
		O.append((t + d, i))
	print(' '.join((str(o[1]) for o in sorted(O))))
main()


T = int(input())
list1 = []
for i in range(0, T):
	(o, t) = map(int, input().split())
	list1.append(o + t)
list2 = sorted(list1)
for i in list2:
	print(list1.index(i) + 1, end=' ')
	list1[list1.index(i)] = 'X'


N = int(input())
orders = sorted([(i, sum(map(int, input().split()))) for i in range(1, N + 1)], key=lambda x: x[1])
for i in orders:
	print(i[0], end=' ')


t = int(input().strip())
finish = []
for i in range(t):
	(s, d) = map(int, input().strip().split())
	finish.append([s + d, i])
finish.sort()
for i in range(t):
	print(finish[i][1] + 1, end=' ')


N = int(input())
l = [(0, 0)]
i = 1
while N > 0:
	(t, d) = (int(_) for _ in input().split())
	c = t + d
	l.append((i, c))
	i += 1
	N -= 1
l.sort(key=lambda t: t[1])
j = []
for (key, value) in l:
	if key != 0:
		j.append(key)
k = list((str(_) for _ in j))
print(' '.join(k))


def solve():
	n = int(input())
	a = [tuple(map(int, input().split())) for _ in range(n)]
	a = [(i + 1, a[i][0], a[i][1]) for i in range(n)]
	a = [(x[0], x[1] + x[2]) for x in a]
	a = sorted(a, key=lambda x: x[1])
	a = [x[0] for x in a]
	print(' '.join(list(map(str, a))))
solve()


def main():
	n = int(input())
	ar = []
	for i in range(n):
		(t, d) = map(int, input().split())
		tmp = (t + d, i + 1)
		ar.append(tmp)
	ar.sort()
	for (a, b) in ar:
		print(b, end=' ')
main()


def solve(sz_arr, arr):
	arr = list(sorted(range(sz_arr), key=lambda x: arr[x][0] + arr[x][1]))
	return ' '.join(map(lambda x: str(x + 1), arr))
arr = []
sz_arr = int(input())
for _ in range(sz_arr):
	arr.append(tuple(list(map(int, input().split()))))
print(solve(sz_arr, arr))