Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits begin to march, so it is only important how many soldiers march in step.

There will be n columns participating in the parade, the i-th column consists of l_{i} soldiers, who start to march from left leg, and r_{i} soldiers, who start to march from right leg.

The beauty of the parade is calculated by the following formula: if L is the total number of soldiers on the parade who start to march from the left leg, and R is the total number of soldiers on the parade who start to march from the right leg, so the beauty will equal |L - R|.

No more than once you can choose one column and tell all the soldiers in this column to switch starting leg, i.e. everyone in this columns who starts the march from left leg will now start it from right leg, and vice versa. Formally, you can pick no more than one index i and swap values l_{i} and r_{i}. 

Find the index of the column, such that switching the starting leg for soldiers in it will maximize the the beauty of the parade, or determine, that no such operation can increase the current beauty.


-----Input-----

The first line contains single integer n (1 ≤ n ≤ 10^5) — the number of columns. 

The next n lines contain the pairs of integers l_{i} and r_{i} (1 ≤ l_{i}, r_{i} ≤ 500) — the number of soldiers in the i-th column which start to march from the left or the right leg respectively.


-----Output-----

Print single integer k — the number of the column in which soldiers need to change the leg from which they start to march, or 0 if the maximum beauty is already reached.

Consider that columns are numbered from 1 to n in the order they are given in the input data.

If there are several answers, print any of them.


-----Examples-----
Input
3
5 6
8 9
10 3

Output
3

Input
2
6 5
5 6

Output
1

Input
6
5 9
1 3
4 8
4 5
23 54
12 32

Output
0



-----Note-----

In the first example if you don't give the order to change the leg, the number of soldiers, who start to march from the left leg, would equal 5 + 8 + 10 = 23, and from the right leg — 6 + 9 + 3 = 18. In this case the beauty of the parade will equal |23 - 18| = 5.

If you give the order to change the leg to the third column, so the number of soldiers, who march from the left leg, will equal 5 + 8 + 3 = 16, and who march from the right leg — 6 + 9 + 10 = 25. In this case the beauty equals |16 - 25| = 9.

It is impossible to reach greater beauty by giving another orders. Thus, the maximum beauty that can be achieved is 9.

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
data = list(map(lambda x: x[0] - x[1], data))
order = [sum(data)]
order.extend(map(lambda x: order[0] - 2 * x, data))
print(order.index(max(order, key=abs)))


n = int(input())
(L, R) = (0, 0)
D = []
for i in range(n):
	(l, r) = map(int, input().split())
	L += l
	R += r
	D.append((l, r))
ans = abs(L - R)
num = 0
for i in range(n):
	(l, r) = D[i]
	L1 = L - l + r
	R1 = R - r + l
	if ans < abs(L1 - R1):
		ans = abs(L1 - R1)
		num = i + 1
print(num)


n = int(input())
suml = 0
sumr = 0
biggestleftinc = 0
blindex = -1
biggestrightinc = 0
brindex = -1
for i in range(n):
	(l, r) = (int(x) for x in input().split())
	suml += l
	sumr += r
	diff = abs(l - r)
	if l > r and diff > biggestleftinc:
		biggestleftinc = diff
		blindex = i
	elif r > l and diff > biggestrightinc:
		biggestrightinc = diff
		brindex = i
if suml == sumr:
	if biggestleftinc == biggestrightinc and biggestleftinc == 0:
		print(0)
	elif biggestleftinc > biggestrightinc:
		print(blindex + 1)
	else:
		print(brindex + 1)
elif sumr > suml:
	righttest = biggestrightinc - (sumr - suml)
	if biggestleftinc > righttest and biggestleftinc > 0:
		print(blindex + 1)
	elif righttest > biggestleftinc:
		print(brindex + 1)
	else:
		print(0)
else:
	lefttest = biggestleftinc - (suml - sumr)
	if biggestrightinc > lefttest and biggestrightinc > 0:
		print(brindex + 1)
	elif lefttest > biggestrightinc:
		print(blindex + 1)
	else:
		print(0)


n = int(input())
(l, r) = ([], [])
for i in range(n):
	x = list(map(int, input().split()))
	l.append(x[0])
	r.append(x[1])
(L, R) = (sum(l), sum(r))
ans = abs(L - R)
ind = 0
for i in range(n):
	x = L - l[i] + r[i]
	y = R - r[i] + l[i]
	if ans < abs(x - y):
		ans = max(ans, abs(x - y))
		ind = i + 1
print(ind)


import sys
input = sys.stdin.readline
inf = int(10000000000.0)
n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
d = [0] * n
for i in range(n):
	d[i] = a[i] - b[i]
(mx, mn, i1, i2) = (-inf, inf, 0, 0)
for i in range(n):
	if d[i] < mn:
		mn = d[i]
		i2 = i
	if d[i] > mx:
		mx = d[i]
		i1 = i
s = sum(a) - sum(b)
if abs(s) > abs(s - 2 * mx) and abs(s) > abs(s - 2 * mn):
	print(0)
elif abs(s - 2 * mx) > abs(s - 2 * mn):
	print(i1 + 1)
else:
	print(i2 + 1)


n = int(input())
ans = 0
left = 0
right = 0
ml = 0
mr = 0
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append((x, y))
	left += x
	right += y
best = abs(left - right)
c = 0
c_ans = 0
for v in a:
	c += 1
	nl = left
	nr = right
	nl = nl - v[0] + v[1]
	nr = nr - v[1] + v[0]
	if abs(nl - nr) > best:
		c_ans = c
		best = abs(nl - nr)
print(c_ans)


from sys import stdin

def main():
	(n,) = stdin_get_ints_from_line()
	pairs = []
	total_l = 0
	total_r = 0
	for i in range(n):
		(l, r) = stdin_get_ints_from_line()
		total_l += l
		total_r += r
		pairs.append((l, r))
	max_beauty_val = abs(total_l - total_r)
	max_beauty_row = 0
	for i in range(n):
		new_max_beauty = total_l - pairs[i][0] + pairs[i][1] - (total_r - pairs[i][1] + pairs[i][0])
		new_max_beauty = abs(new_max_beauty)
		if new_max_beauty > max_beauty_val:
			max_beauty_val = new_max_beauty
			max_beauty_row = i + 1
	print(max_beauty_row)
	return

def stdin_get_ints_from_line():
	return (int(x) for x in stdin.readline().strip().split(' '))

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))

def stdin_get_string_from_line():
	return stdin.readline().strip()
main()


import sys

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

def beauty(x):
	return x[1] - x[2]

def max_beauty(x):
	return x[1]

def readLR(f, i):
	(l, r) = (int(x) for x in f.readline()[:-1].split(' '))
	return (i, l, r)
n = int(sys.stdin.readline()[:-1])
lr = [readLR(sys.stdin, i) for i in range(n)]
sortedlr = sorted(lr, key=beauty)
(L, R) = (0, 0)
for (i, l, r) in lr:
	L += l
	R += r
bea = abs(L - R)
tries = [(-1, bea)]
tries += [(sortedlr[-1][0], abs(L - R - 2 * beauty(sortedlr[-1])))]
tries += [(sortedlr[0][0], abs(L - R - 2 * beauty(sortedlr[0])))]
best = sorted(tries, key=max_beauty)[-1]
if best[1] == bea:
	sys.stdout.write(str(0))
else:
	sys.stdout.write(str(best[0] + 1))


a = int(input())
(v, r, t, l) = ([], 0, -1, 0)
for i in range(a):
	(q, w) = map(int, input().split())
	v.append([q, w])
	l += q
	r += w
b = abs(l - r)
for i in range(len(v)):
	w = abs(l + v[i][1] - v[i][0] - (r + v[i][0] - v[i][1]))
	if w > b:
		(t, b) = (i, w)
print(t + 1)


n = int(input())
coloms = [[None, None] for i in range(n)]
for i in range(n):
	(coloms[i][0], coloms[i][1]) = list(map(int, input().split()))
left_men = sum([t[0] for t in coloms])
right_men = sum([t[1] for t in coloms])
beauty = abs(left_men - right_men)
first = beauty
ans = 0
for i in range(n):
	colom = coloms[i]
	new_beauty = abs(left_men - colom[0] + colom[1] - (right_men - colom[1] + colom[0]))
	if new_beauty > beauty:
		ans = i + 1
		beauty = new_beauty
print(ans)


n = int(input())
cols = []
for i in range(n):
	cols.append(list(map(int, input().split())))
left = 0
right = 0
for col in cols:
	left += col[0]
	right += col[1]
best = -1
max_raze = abs(right - left)
for i in range(n):
	_sleft = left - cols[i][0] + cols[i][1]
	_sright = right - cols[i][1] + cols[i][0]
	if abs(_sleft - _sright) > max_raze:
		best = i
		max_raze = abs(_sleft - _sright)
print(best + 1)


n = int(input())
a = []
b = []
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
x = sum(a)
y = sum(b)
ans = abs(x - y)
ind = 0
for i in range(n):
	z = abs(x - a[i] + b[i] - (y - b[i] + a[i]))
	if z > ans:
		ans = z
		ind = i + 1
print(ind)


num = int(input())
a = [0] * num
b = [0] * num
sum1 = sum2 = 0
for i in range(0, num):
	(a[i], b[i]) = tuple((int(i) for i in input().strip().split(' ')))
sum1 = sum(a)
sum2 = sum(b)
mx = abs(sum1 - sum2)
index = 0
for i in range(0, num):
	sum1 = sum1 - a[i] + b[i]
	sum2 = sum2 - b[i] + a[i]
	if mx < abs(sum1 - sum2):
		mx = abs(sum1 - sum2)
		index = i + 1
	sum1 = sum1 - b[i] + a[i]
	sum2 = sum2 - a[i] + b[i]
print(index)


n = int(input())
L = 0
R = 0
lev = []
prav = []
kol = 0
for i in range(n):
	(l, r) = map(int, input().split())
	L += l
	R += r
	lev += [l]
	prav += [r]
maxkr = max(L, R) - min(L, R)
L1 = L
R1 = R
for i in range(len(lev)):
	L -= lev[i]
	R -= prav[i]
	L += prav[i]
	R += lev[i]
	kr = max(L, R) - min(L, R)
	if kr > maxkr:
		maxkr = kr
		kol = i + 1
	L = L1
	R = R1
print(kol)


n = int(input())
l = []
r = []
i = 0
ma = 0
t = -1
s1 = 0
s2 = 0
for i in range(n):
	l.append(0)
	r.append(0)
	(l[i], r[i]) = map(int, input().split())
for i in range(n):
	s1 += l[i]
	s2 += r[i]
ma = abs(s1 - s2)
for i in range(n):
	if abs(s1 - l[i] + r[i] - (s2 - r[i] + l[i])) > ma:
		ma = abs(s1 - l[i] + r[i] - (s2 - r[i] + l[i]))
		t = i
print(t + 1)


from queue import PriorityQueue
fmap = lambda f, l: list(map(f, l))
parse_int = lambda : fmap(int, input().split())
(prl, prr) = (0, 0)
(il, ir) = (0, 0)
(lsum, rsum) = (0, 0)
for idx in range(int(input())):
	(l, r) = parse_int()
	lsum += l
	rsum += r
	if r - l > prl:
		il = idx
		prl = r - l
	if l - r > prr:
		ir = idx
		prr = l - r
if lsum + prl > rsum + prr:
	if prl > 0:
		print(il + 1)
	else:
		print(0)
elif prr > 0:
	print(ir + 1)
else:
	print(0)


l = [0] + [sum(map(int, ('-' + input()).split())) for _ in range(int(input()))]
(s, a, b) = (sum(l), min(l), max(l))
print(l.index(b if s < a + b else a))


n = int(input())
L = [0]
R = [0]
for _ in range(1, n + 1):
	(x, y) = map(int, input().split())
	L.append(x)
	R.append(y)
maxk = 0
(sL, sR) = (sum(L), sum(R))
maxb = abs(sL - sR)
for k in range(1, n + 1):
	b = abs(sL - sR - 2 * L[k] + 2 * R[k])
	if b > maxb:
		(maxk, maxb) = (k, b)
print(maxk)


n = int(input())
sl = 0
sr = 0
columns = []
for i in range(n):
	columns.append(list(map(int, input().split())))
	sl += columns[-1][0]
	sr += columns[-1][1]
beauty = abs(sl - sr)
new_beauty = beauty
index = -1
for (i, j) in enumerate(columns):
	new_sl = sl - j[0]
	new_sr = sr - j[1]
	new_sl += j[1]
	new_sr += j[0]
	tmp_beauty = abs(new_sl - new_sr)
	if tmp_beauty > new_beauty:
		new_beauty = tmp_beauty
		index = i
print(0) if index == -1 else print(index + 1)


n = int(input())
lrr = []
rrr = []
ls = 0
rs = 0
for i in range(n):
	(a, b) = map(int, input().split())
	lrr.append(a)
	rrr.append(b)
	ls += a
	rs += b
mx = abs(ls - rs)
mxi = 0
for i in range(n):
	k = abs(ls - lrr[i] + rrr[i] - (rs - rrr[i] + lrr[i]))
	if mx < k:
		mx = k
		mxi = i + 1
print(mxi)


n = int(input())
L = 0
R = 0
a = []
pas = 0
for _ in range(n):
	(l, r) = map(int, input().split())
	L += l
	R += r
	a.append(l - r)
b = abs(L - R)
k = b
for i in range(n):
	if abs(L - a[i] - (R + a[i])) > k:
		k = abs(L - a[i] - (R + a[i]))
		pas = i + 1
if k == b:
	print(0)
else:
	print(pas)


diff1 = int(0)
diff2 = int(0)
pos1 = int(0)
pos2 = int(0)
current = int(0)
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if y - x > diff1:
		pos1 = i + 1
		diff1 = y - x
	if x - y > diff2:
		pos2 = i + 1
		diff2 = x - y
	current += x - y
print(pos1 if abs(current + 2 * diff1) > abs(current - 2 * diff2) else pos2)


n = int(input())
l = []
r = []
for i in range(0, n):
	lr = list(map(int, input().split()))
	l.append(lr[0])
	r.append(lr[1])
diff = []
inital = abs(sum(l) - sum(r))
for i in range(0, n):
	diff.append(l[i] - r[i])
i1 = diff.index(max(diff))
i2 = diff.index(min(diff))
(l[i1], r[i1]) = (r[i1], l[i1])
ans1 = abs(sum(l) - sum(r))
(l[i1], r[i1]) = (r[i1], l[i1])
(l[i2], r[i2]) = (r[i2], l[i2])
ans2 = abs(sum(l) - sum(r))
if ans1 > ans2 and ans1 > inital:
	print(i1 + 1)
elif ans2 > ans1 and ans2 > inital:
	print(i2 + 1)
elif ans1 == ans2 and ans1 > inital:
	print(i1 + 1)
else:
	print(0)


n = int(input())
l1 = []
r1 = []
L = 0
R = 0
for i in range(n):
	(l, r) = map(int, input().split())
	L += l
	R += r
	l1.append(l)
	r1.append(r)
max = abs(L - R)
ans = 0
for i in range(n):
	if abs(L - l1[i] + r1[i] - (R - r1[i] + l1[i])) > max:
		max = abs(L - l1[i] + r1[i] - (R - r1[i] + l1[i]))
		ans = i + 1
print(ans)


from sys import stdin
lines = stdin.read().splitlines()
lines.pop(0)
rows = []
initialLeftSum = 0
initialRightSum = 0
for line in lines:
	row = [int(x) for x in line.split()]
	rows.append(row)
	initialLeftSum += row[0]
	initialRightSum += row[1]
maxBeauty = abs(initialLeftSum - initialRightSum)
rowtoswitch = 0
for (idx, row) in enumerate(rows):
	rowMaxBeauty = abs(initialLeftSum - initialRightSum + 2 * (row[1] - row[0]))
	if rowMaxBeauty > maxBeauty:
		maxBeauty = rowMaxBeauty
		rowtoswitch = idx + 1
print(rowtoswitch)


import math
n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = [int(i) for i in input().rsplit(' ')]
s = 0
for i in range(n):
	s += l[i] - r[i]
bestDiff = math.fabs(s)
bestIndex = -1
for i in range(n):
	if math.fabs(s + 2 * (r[i] - l[i])) > bestDiff:
		bestDiff = math.fabs(s + 2 * (r[i] - l[i]))
		bestIndex = i
	else:
		pass
print(bestIndex + 1)


n = int(input())
l = []
r = []
la = 0
ra = 0
for i in range(n):
	(L, R) = map(int, input().split())
	l.append(L)
	r.append(R)
	la += l[i]
	ra += r[i]
ans = 0
nice = abs(la - ra)
for i in range(n):
	if abs(la - l[i] + r[i] - (ra - r[i] + l[i])) > nice:
		ans = i + 1
		nice = abs(la - l[i] + r[i] - (ra - r[i] + l[i]))
print(ans)


n = int(input())
d_vec = [0]
for i in range(n):
	(l, u) = [int(i) for i in input().split()]
	d_vec.append(l - u)
d_sum = sum(d_vec)
d_vec = [abs(d_sum - 2 * d) for d in d_vec]
d_max = max(d_vec)
print(d_vec.index(d_max))


n = int(input())
l = []
r = []
for i in range(n):
	(li, ri) = map(int, input().split(' '))
	l.append(li)
	r.append(ri)
L = sum(l)
R = sum(r)
beauty = abs(L - R)
best = -1
for i in range(n):
	LL = L - l[i] + r[i]
	RR = R - r[i] + l[i]
	pos_beauty = abs(LL - RR)
	if pos_beauty > beauty:
		beauty = pos_beauty
		best = i
print(best + 1)


N = int(input())
left = []
right = []
for i in range(0, N):
	(l, r) = input().split(' ')
	left.append(int(l))
	right.append(int(r))
leftSum = sum(left)
rightSum = sum(right)
sumDiff = leftSum - rightSum
absBeauty = abs(leftSum - rightSum)
maxBeauty = absBeauty
maxColumn = -1
for i in range(0, N):
	swapBeauty = abs(sumDiff - 2 * left[i] + 2 * right[i])
	if swapBeauty > maxBeauty:
		maxBeauty = swapBeauty
		maxColumn = i
print(maxColumn + 1)


n = int(input())
heh = []
ans = 0
LminusR = 0
for i in range(n):
	(l, r) = map(int, input().split())
	LminusR += l
	LminusR -= r
	heh.append(2 * (r - l))
kok = abs(LminusR)
for e in range(n):
	i = heh[e]
	if abs(LminusR + i) > kok:
		kok = abs(LminusR + i)
		ans = e + 1
print(ans)


def main():
	a = int(input())
	b = []
	result = (0, 0)
	result2 = (0, 0)
	list1 = []
	list2 = []
	for i in range(a):
		k = input()
		k = k.split()
		list1.append(int(k[0]))
		list2.append(int(k[1]))
	left = 0
	right = 0
	for i in range(a):
		if list1[i] > list2[i]:
			left += 1
		elif list1[i] < list2[i]:
			right += 1
	if left == 0 or right == 0:
		return 0
	for i in range(a):
		if list2[i] - list1[i] > result[0]:
			result = (list2[i] - list1[i], i + 1)
		elif list1[i] - list2[i] > result2[0]:
			result2 = (list1[i] - list2[i], i + 1)
	list1_2 = list(list1)
	list2_2 = list(list2)
	(list1_2[result[1] - 1], list2_2[result[1] - 1]) = (list2_2[result[1] - 1], list1_2[result[1] - 1])
	(list1[result2[1] - 1], list2[result2[1] - 1]) = (list2[result2[1] - 1], list1[result2[1] - 1])
	if abs(sum(list1) - sum(list2)) > abs(sum(list1_2) - sum(list2_2)):
		return result2[1]
	return result[1]
print(main())


n = int(input())
t_l = 0
t_r = 0
m_l = 0
m_l_i = 0
m_r = 0
m_r_i = 0
a_n = [[0 for _ in range(2)] for _ in range(n)]
for i in range(n):
	(l, r) = map(int, input().split())
	t_l += l
	t_r += r
	a_n[i][0] = l
	a_n[i][1] = r
max_k = abs(t_l - t_r)
o = 0
for i in range(n):
	if abs(t_l - a_n[i][0] + a_n[i][1] - (t_r - a_n[i][1] + a_n[i][0])) > max_k:
		max_k = abs(t_l - a_n[i][0] + a_n[i][1] - (t_r - a_n[i][1] + a_n[i][0]))
		o = i + 1
print(o)


n = int(input())
(L, R) = (0, 0)
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	L += l
	R += r
	a.append([l, r])
ans = [L, R, 0]
for i in range(n):
	nL = L - a[i][0] + a[i][1]
	nR = R - a[i][1] + a[i][0]
	if abs(ans[0] - ans[1]) < abs(nL - nR):
		ans = [nL, nR, i + 1]
print(ans[2])


n = int(input())
minusas = 0
minuso_k = 0
pliusas = 0
pliuso_k = 0
suma = 0
for i in range(n):
	(k, l) = map(int, input().split())
	t = k - l
	if t < minusas:
		minusas = t
		minuso_k = i + 1
	elif t > pliusas:
		pliusas = t
		pliuso_k = i + 1
	suma += k - l
if abs(suma - 2 * pliusas) > abs(suma - 2 * minusas):
	print(pliuso_k)
else:
	print(minuso_k)


import sys

def solve(L, R):
	n = len(L)
	d = sum(R) - sum(L)
	p = max(((abs(2 * (L[i] - R[i]) + d), i) for i in range(n)))
	return p[1] + 1 if p[0] > abs(d) else 0
n = int(input())
(L, R) = ([], [])
for line in sys.stdin:
	(l, r) = map(int, line.split())
	L.append(l)
	R.append(r)
print(solve(L, R))


n = int(input())
l_lst = []
r_lst = []
for i in range(n):
	(l, r) = list(map(int, input().split()))
	l_lst.append(l)
	r_lst.append(r)
c_beauty = abs(sum(l_lst) - sum(r_lst))
index = 0
left = sum(l_lst)
right = sum(r_lst)
for i in range(n):
	if abs(left - l_lst[i] + r_lst[i] - (right + l_lst[i] - r_lst[i])) > c_beauty:
		c_beauty = abs(left - l_lst[i] + r_lst[i] - (right + l_lst[i] - r_lst[i]))
		index = i + 1
print(index)


value = 0
va = 0
clist = []
blist = []
for i in range(int(input())):
	a = input().split()
	b = int(a[0])
	c = int(a[1])
	blist.append(b)
	clist.append(c)
maxb = sum(blist)
maxc = sum(clist)
for i in range(len(blist)):
	b = blist[i]
	c = clist[i]
	if abs(maxb - b + c - (maxc - c + b)) > value and abs(maxb - b + c - (maxc - c + b)) > abs(maxb - maxc):
		value = abs(maxb - b + c - (maxc - c + b))
		va = i + 1
print(va)


n = int(input())
(pairs, lsum, rsum) = ([], 0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	pairs.append((a, b))
	lsum += a
	rsum += b
x = abs(lsum - rsum)
index = -1
for i in range(n):
	(l, r) = (lsum, rsum)
	l = l - pairs[i][0]
	r = r - pairs[i][1]
	l += pairs[i][1]
	r += pairs[i][0]
	a = abs(l - r)
	if a > x:
		x = a
		index = i + 1
if index == -1:
	print(0)
else:
	print(index)


n = int(input())
T = []
J = []
l = 0
r = 0
for i in range(n):
	(L, R) = map(int, input().split())
	T.append(L)
	J.append(R)
	l += L
	r += R
B = abs(l - r)
ind = 0
for i in range(n):
	x = T[i]
	y = J[i]
	h = abs(l - x + y - (r + x - y))
	if B < h:
		B = h
		ind = i + 1
print(ind)


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

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

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

def l():
	return list(sp())

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

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

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

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

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(1):
	n = l()[0]
	A = [l() for i in range(n)]
	L = sum((A[i][0] for i in range(n)))
	R = sum((A[i][1] for i in range(n)))
	idx = 0
	mx = abs(L - R)
	for i in range(n):
		x = L + A[i][1] - A[i][0]
		y = R + A[i][0] - A[i][1]
		if mx < abs(x - y):
			idx = i + 1
			mx = abs(x - y)
	print(idx)


n = int(input())
num = [list(map(int, input().strip().split())) for i in range(n)]
(L, R) = (sum([x[0] for x in num]), sum([x[1] for x in num]))
pre = L - R
ans = abs(pre)
ind = -1
for (i, x) in enumerate(num):
	cur = abs(pre + 2 * (x[1] - x[0]))
	if cur > ans:
		(ans, ind) = (cur, i)
print(ind + 1)


n = int(input())
sum = 0
a = []
b = []
for i in range(0, n):
	c = input()
	c = c.split()
	a.append(int(c[0]))
	b.append(int(c[1]))
	sum += a[i] - b[i]
v = abs(sum)
ans = -1
for i in range(0, n):
	vv = sum - 2 * (a[i] - b[i])
	vv = abs(vv)
	if vv > v:
		v = vv
		ans = i
print(ans + 1)


l = []
r = []
sum_r = 0
sum_l = 0
max_diff_r = 0
max_r = 0
max_diff_l = 0
max_l = 0
for i in range(0, int(input())):
	(x, y) = input().split(' ')
	l.append(int(x))
	sum_l += l[i]
	r.append(int(y))
	sum_r += r[i]
	if max_diff_r < r[i] - l[i]:
		max_r = i + 1
		max_diff_r = r[i] - l[i]
	if max_diff_l < l[i] - r[i]:
		max_l = i + 1
		max_diff_l = l[i] - r[i]
d = max(abs(sum_r - sum_l), sum_l - sum_r + 2 * max_diff_r, sum_r - sum_l + 2 * max_diff_l)
if d == abs(sum_r - sum_l):
	print(0)
elif d == sum_r - sum_l + 2 * max_diff_l:
	print(max_l)
else:
	print(max_r)


n = int(input())
tl = 0
tr = 0
cols = [[0, 0]]
for _ in range(n):
	(l, r) = map(int, input().split())
	tl += l
	tr += r
	cols.append((l, r))
beauty = abs(tl - tr)
best = 0
for i in range(1, n + 1):
	tl2 = tl - cols[i][0] + cols[i][1]
	tr2 = tr - cols[i][1] + cols[i][0]
	b2 = abs(tl2 - tr2)
	if b2 > beauty:
		beauty = b2
		best = i
print(best)


n = int(input())
a = []
(l, r) = (0, 0)
b = 0
c = -1
for i in range(n):
	a.append([int(x) for x in input().split()])
	(l, r) = (l + a[i][0], r + a[i][1])
b = abs(l - r)
for i in range(n):
	d = abs(l - a[i][0] + a[i][1] - (r - a[i][1] + a[i][0]))
	if d > b:
		b = d
		c = i
print(c + 1)


__author__ = 'Alexander'
n = input()
n = int(n)
l = []
r = []
L0 = 0
R0 = 0
for i in range(n):
	s = input()
	(lt, rt) = map(int, s.split())
	l.append(lt)
	r.append(rt)
	L0 += lt
	R0 += rt
B0 = abs(L0 - R0)
BN = B0
N = 0
for i in range(n):
	L = L0 - l[i] + r[i]
	R = R0 - r[i] + l[i]
	B = abs(L - R)
	if B > BN:
		BN = B
		N = i + 1
print(N)


n = int(input())
dl = []
ans = L = R = 0
for i in range(n):
	(l, r) = map(int, input().split())
	L += l
	R += r
	dl += [[l, r]]
ans = abs(L - R)
index = -1
for i in range(n):
	ts = abs(L - R + 2 * (-dl[i][0] + dl[i][1]))
	if ts > ans:
		ans = ts
		index = i
print(index + 1)


n = int(input())
l = []
r = []
suml = 0
sumr = 0
for i in range(n):
	(a, b) = input().split(' ')
	l.append(int(a))
	r.append(int(b))
	suml += int(a)
	sumr += int(b)
diff = abs(suml - sumr)
index = -1
for i in range(n):
	if abs(suml - l[i] + r[i] - (sumr - r[i] + l[i])) > diff:
		diff = abs(suml - l[i] + r[i] - (sumr - r[i] + l[i]))
		index = i
print(index + 1)


n = int(input())
sum_ls = []
diff = 0
res = 0
rec = 0
for i in range(n):
	tmp = input()
	tmp = tmp.split(' ')
	sum_ls.append(int(tmp[0]) - int(tmp[1]))
	diff += sum_ls[i]
for p in range(len(sum_ls)):
	if res < abs(diff - sum_ls[p] * 2) and abs(diff - sum_ls[p] * 2) > abs(diff):
		res = abs(diff - sum_ls[p] * 2)
		rec = p + 1
if rec:
	print(str(rec))
else:
	print('0')


a = []
for i in range(int(input())):
	(l, r) = map(int, input().split())
	a.append(l - r)
s = sum(a)
(v, vi) = (s, -1)
for (i, ai) in enumerate(a):
	c = s - 2 * ai
	if abs(c) > abs(v):
		(v, vi) = (c, i)
print(vi + 1)


chislo = int(input())
mas = []
Left = 0
Right = 0
Index = 0
for i in range(chislo):
	a = list(map(int, input().split()))
	Left += a[0]
	Right += a[1]
	mas.append(a)
Max = abs(Left - Right)
for razi in range(len(mas)):
	if abs(Left - mas[razi][0] + mas[razi][1] - (Right - mas[razi][1] + mas[razi][0])) > Max:
		Max = abs(Left - mas[razi][0] + mas[razi][1] - (Right - mas[razi][1] + mas[razi][0]))
		Index = razi + 1
print(Index)


n = int(input())
L = []
R = []
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	L.append(l)
	R.append(r)
t = sum(L)
r = sum(R)
v = abs(t - r)
s = 0
for j in range(n):
	k = abs(t - L[j] + R[j] - (r - R[j] + L[j]))
	if k > v:
		v = k
		s = j + 1
print(s)


def main():
	n = int(input())
	l = [0] * n
	r = [0] * n
	for i in range(n):
		(l[i], r[i]) = [int(x) for x in input().split()]
	total_r = sum(r)
	total_l = sum(l)
	beauty = abs(total_l - total_r)
	(new_beauty, row) = max(((abs(total_l - total_r + 2 * r[i] - 2 * l[i]), i) for i in range(n)))
	if new_beauty <= beauty:
		print(0)
	else:
		print(row + 1)
main()


n = int(input())
ans = 0
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x - y)
s = sum(a)
ans = [abs(s)]
for i in range(n):
	ans.append(abs(s - 2 * a[i]))
print(ans.index(max(ans)))


n = int(input())
mass = []
for i in range(n):
	(a, b) = map(int, input().split())
	mass.append(a - b)
minm = min(mass)
if minm > 0:
	minm = 0
maxm = max(mass)
if maxm < 0:
	maxm = 0
summ = sum(mass)
res = -1
if abs(summ - maxm - maxm) > abs(summ) and abs(summ - minm - minm) < abs(summ - maxm - maxm):
	summ -= 2 * maxm
	res = mass.index(maxm)
elif abs(summ - minm - minm) > abs(summ):
	summ -= 2 * minm
	res = mass.index(minm)
print(res + 1)


n = int(input())
columns = []
l_tot = 0
r_tot = 0
for i in range(n):
	(l, r) = [int(j) for j in input().split()]
	columns.append((l, r))
	l_tot += l
	r_tot += r
beauty = abs(l_tot - r_tot)
best_idx = -1
for (i, c) in enumerate(columns):
	(l, r) = c
	tmp_beauty = abs(l_tot - l + r - (r_tot - r + l))
	if tmp_beauty > beauty:
		beauty = tmp_beauty
		best_idx = i
if best_idx < 0:
	print(0)
else:
	print(best_idx + 1)


n = int(input())
l = [0] * n
r = [0] * n
L = 0
R = 0
for i in range(n):
	(a, b) = map(int, input().split())
	l[i] = a
	L += a
	r[i] = b
	R += b
Mx = abs(R - L)
j = 0
for i in range(n):
	if abs(R - r[i] + l[i] - (L - l[i] + r[i])) > Mx:
		Mx = abs(R - r[i] + l[i] - (L - l[i] + r[i]))
		j = i + 1
print(j)


from sys import stdin

def main():
	numLines = int(stdin.readline())
	columns = []
	columns.append([])
	columns.append([])
	for i in range(numLines):
		line = stdin.readline()
		words = line.split()
		columns[0].append(int(words[0]))
		columns[1].append(int(words[1]))
	(maxBeauty, columnSwap) = find_max_beauty(columns)
	print(columnSwap)

def find_max_beauty(columns):
	left = sum(columns[0])
	right = sum(columns[1])
	maxBeauty = abs(left - right)
	columnSwap = 0
	for i in range(len(columns[0])):
		newLeft = left - columns[0][i] + columns[1][i]
		newRight = right - columns[1][i] + columns[0][i]
		tempMax = abs(newLeft - newRight)
		if tempMax > maxBeauty:
			maxBeauty = tempMax
			columnSwap = i + 1
	return (maxBeauty, columnSwap)
main()


n = int(input())
a = [0] * n
l = 0
r = 0
for i in range(n):
	a[i] = list(map(int, input().split()))
	l += a[i][0]
	r += a[i][1]
best = abs(l - r)
ans = 0
for i in range(n):
	new = abs(l - a[i][0] + a[i][1] - (r - a[i][1] + a[i][0]))
	if new > best:
		best = new
		ans = i + 1
print(ans)


n = int(input())
(l, r) = ([0] * n, [0] * n)
for i in range(n):
	(l[i], r[i]) = map(int, input().split(' '))
(L, R) = (sum(l), sum(r))
(index, beauty) = (-1, abs(L - R))
for i in range(n):
	t = abs(L - l[i] + r[i] - (R - r[i] + l[i]))
	if t > beauty:
		(index, beauty) = (i, t)
print(index + 1)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
n = vary(1)
left = []
right = []
for i in range(n):
	(l, r) = vary(2)
	left.append(l)
	right.append(r)
lsum = sum(left)
rsum = sum(right)
curr = abs(lsum - rsum)
maxi = -1
ans = 0
for i in range(n):
	if abs(lsum - left[i] + right[i] - (rsum - right[i] + left[i])) > curr and abs(lsum - left[i] + right[i] - (rsum - right[i] + left[i])) > maxi:
		maxi = abs(lsum - left[i] + right[i] - (rsum - right[i] + left[i]))
		ans = i + 1
print(ans)


x = int(input())
t = 0
t1 = 0
k = 0
k1 = 0
i = 0
r = 0
r1 = 0
for i in range(1, x + 1):
	a = list(map(int, input().split()))
	t = t + a[0]
	k = max(a[0] - a[1], k)
	if k == a[0] - a[1]:
		r = i
	t1 = t1 + a[1]
	k1 = max(a[1] - a[0], k1)
	if k1 == a[1] - a[0]:
		r1 = i
if t + k1 > t1 + k:
	print(r1)
else:
	print(r)


n = int(input())
l = [0 for i in range(n)]
r = [0 for i in range(n)]
leftSumm = 0
rightSumm = 0
for i in range(n):
	(l[i], r[i]) = list(map(int, input().split()))
	leftSumm += l[i]
	rightSumm += r[i]
result = -1
maxresult = abs(leftSumm - rightSumm)
for i in range(n):
	tempLeft = leftSumm - l[i] + r[i]
	tempRight = rightSumm - r[i] + l[i]
	if abs(tempLeft - tempRight) > maxresult:
		maxresult = abs(tempLeft - tempRight)
		result = i
print(result + 1)


n = int(input())
(left, right) = ([], [])
for _ in range(n):
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(r)
lsum = sum(left)
rsum = sum(right)
beauty = abs(lsum - rsum)
ans = -1
for i in range(n):
	new_beauty = abs(lsum - left[i] + right[i] - (rsum - right[i] + left[i]))
	if new_beauty > beauty:
		ans = i
		beauty = new_beauty
print(ans + 1)


n = int(input())
m = []
for i in range(n):
	x = input().split()
	x[0] = int(x[0])
	x[1] = int(x[1])
	m.append(x)
res = []
L = 0
R = 0
for y in range(n):
	L += m[y][0]
	R += m[y][1]
res.append(abs(L - R))
for i in range(n):
	L1 = L - m[i][0] + m[i][1]
	R1 = R - m[i][1] + m[i][0]
	res.append(abs(L1 - R1))
print(res.index(max(res)))


sl = 0
sr = 0
d = []
n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	sl += l
	sr += r
	d.append([l - r, i + 1])
d.sort()
md = sl - sr
ans = 0
ad = abs(md)
if abs(md - d[0][0] * 2) > ad:
	ans = d[0][1]
	ad = abs(md - d[0][0] * 2)
if abs(md - d[-1][0] * 2) > ad:
	ans = d[-1][1]
	ad = abs(md - d[-1][0])
print(ans)


from sys import *
input = stdin.readline
n = int(input())
arr = []
arr2 = []
l = 0
r = 0
for _ in range(n):
	ll = list(map(int, input().split()))
	arr.append(ll)
	arr2.append([ll[1], ll[0]])
	l += ll[0]
	r += ll[1]
bu = abs(l - r)
ans = 0
for i in range(n):
	(a, b) = (arr[i][0], arr[i][1])
	smh = abs(l - a + b - (r - b + a))
	if smh > bu:
		bu = smh
		ans = i + 1
print(ans)


n = int(input())
a = [0] * n
R = 0
L = 0
for i in range(n):
	a[i] = list(map(int, input().split()))
	R += a[i][1]
	L += a[i][0]
m = abs(L - R)
ans = 0
for i in range(n):
	b = abs(L - a[i][0] + a[i][1] - (R - a[i][1] + a[i][0]))
	if b > m:
		ans = i + 1
		m = b
print(ans)


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

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

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

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

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

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

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

def S():
	return input()

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

def main():
	n = I()
	a = [LI() for _ in range(n)]
	ls = sum(map(lambda x: x[0], a))
	rs = sum(map(lambda x: x[1], a))
	rr = -1
	m = abs(ls - rs)
	for i in range(n):
		(l, r) = a[i]
		tl = ls - l + r
		tr = rs + l - r
		t = abs(tl - tr)
		if m < t:
			m = t
			rr = i
	return rr + 1
print(main())


n = int(input())
C = [list(map(int, input().split())) for i in range(n)]
L = sum([C[i][0] for i in range(n)])
R = sum([C[i][1] for i in range(n)])
if 1:
	ml = 0
	mr = 0
	ind1 = -1
	ind2 = -1
	for i in range(n):
		if C[i][1] - C[i][0] > ml:
			ml = C[i][1] - C[i][0]
			ind1 = i
		elif C[i][0] - C[i][1] > mr:
			mr = C[i][0] - C[i][1]
			ind2 = i
D = abs(L - R)
D1 = abs(L + C[ind1][1] - C[ind1][0] - (R + C[ind1][0] - C[ind1][1]))
D2 = abs(L + C[ind2][1] - C[ind2][0] - (R + C[ind2][0] - C[ind2][1]))
if D1 > D2 and D2 > D:
	print(1 + ind1)
elif D2 > D1 and D1 > D:
	print(1 + ind2)
elif D2 > D:
	print(1 + ind2)
elif D1 > D:
	print(1 + ind1)
else:
	print(0)


N = int(input())
lister = [0] * N
total = 0
miny = 0
maxy = 0
maxi = 0
mini = 0
for x in range(N):
	(a, b) = (int(a) for a in input().split())
	lister[x] = a - b
	total += a - b
	if miny > a - b:
		miny = a - b
		mini = x + 1
	if maxy < a - b:
		maxy = a - b
		maxi = x + 1
maxtotal = abs(total)
bestind = 0
T = abs(total - 2 * maxy)
if maxtotal < T:
	maxtotal = T
	bestind = maxi
T = abs(total - 2 * miny)
if maxtotal < T:
	maxtotal = T
	bestind = mini
print(bestind)


n = int(input())
a = [0] * n
b = [0] * n
c = [0] * n
d = []
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
	c[i] = a[i] - b[i]
sa = sum(a)
sb = sum(b)
if max(c) <= 0 or min(c) >= 0:
	print(0)
else:
	for i in range(n):
		d.append(abs(sa - c[i] - (sb + c[i])))
	print(d.index(max(d)) + 1)


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
s1 = 0
s2 = 0
j = -1
for i in range(n):
	s1 = s1 + l[i][0]
	s2 = s2 + l[i][1]
p = abs(s1 - s2)
for i in range(n):
	s3 = s1 - l[i][0] + l[i][1]
	s4 = s2 + l[i][0] - l[i][1]
	q = abs(s3 - s4)
	if q > p:
		j = i
		p = q
print(j + 1)


n = int(input())
left = []
right = []
for i in range(n):
	(a, b) = map(int, input().split())
	left.append(a)
	right.append(b)
l = sum(left)
r = sum(right)
beauty = abs(l - r)
row = 0
for i in range(n):
	l = l - left[i] + right[i]
	r = r - right[i] + left[i]
	tmp = abs(l - r)
	if tmp > beauty:
		row = i + 1
		beauty = tmp
	l = l - right[i] + left[i]
	r = r - left[i] + right[i]
print(row)


n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	l[i] = l[i][0] - l[i][1]
ans = 0
su = sum(l)
ma = abs(su)
for i in range(n):
	if abs(su - l[i] - l[i]) > ma:
		ma = abs(su - l[i] - l[i])
		ans = i + 1
print(ans)


n = int(input())
t = []
for i in range(n):
	(l, r) = map(int, input().split())
	t.append((l, r))
L = 0
R = 0
for i in t:
	L += i[0]
	R += i[1]
m = abs(L - R)
mi = 0
for i in range(n):
	(l, r) = (t[i][0], t[i][1])
	if l == r:
		continue
	d = abs(L - l + r - (R - r + l))
	if d > m:
		m = d
		mi = i
if m == abs(L - R):
	print(0)
else:
	print(mi + 1)


n = int(input())
c = -1
d = -1
sum1 = 0
sum2 = 0
str2 = [] * (n + 1)
str1 = [] * (n + 1)
for i in range(n):
	[a, b] = input().split(' ')
	a = int(a)
	sum1 = sum1 + a
	b = int(b)
	sum2 = sum2 + b
	str1.append(a)
	str2.append(b)
num = abs(sum1 - sum2)
for i in range(n):
	if num < abs(sum1 - str1[i] + str2[i] - (sum2 - str2[i] + str1[i])):
		num = abs(sum1 - str1[i] + str2[i] - (sum2 - str2[i] + str1[i]))
		c = i
if c < 0:
	print(0)
else:
	print(c + 1)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
sum_arr = [i[0] - i[-1] for i in l]
Sum = sum(sum_arr)
ans = [(abs(Sum), 0)]
for (i, j) in enumerate(sum_arr, 1):
	ans.append((abs(Sum - 2 * j), i))
print(max(ans)[-1])


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
left = 0
right = 0
for i in range(n):
	left += l[i][0]
	right += l[i][1]
maxdiff = abs(left - right)
a = 0
for i in range(n):
	k = abs(left + l[i][1] - l[i][0] - (right + l[i][0] - l[i][1]))
	if k > maxdiff:
		maxdiff = k
		index = i + 1
		a = 1
if a == 0:
	print(0)
else:
	print(index)


n = int(input())
l = [0] * n
r = [0] * n
L = R = 0
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
	L += l[i]
	R += r[i]
m = abs(L - R)
j = -1
for i in range(n):
	k = abs(L - 2 * l[i] + 2 * r[i] - R)
	if k > m:
		m = k
		j = i
print(j + 1)


t = int(input())
sum1 = 0
sum2 = 0
ans = []
l = []
for _ in range(t):
	(n, m) = map(int, input().split())
	l.append([n, m])
	sum1 += n
	sum2 += m
final = abs(sum1 - sum2)
ind = -1
for i in range(t):
	temp = sum1
	temp2 = sum2
	temp = temp - l[i][0] + l[i][1]
	temp2 = temp2 - l[i][1] + l[i][0]
	if abs(temp - temp2) > final:
		final = abs(temp - temp2)
		ind = i + 1
if ind == -1:
	print('0')
else:
	print(ind)


n = int(input())
d = []
for i in range(n):
	(a, b) = map(int, input().split())
	d.append([a, b])
(L, R) = (0, 0)
for i in range(n):
	L += d[i][0]
	R += d[i][1]
max = abs(L - R)
imax = -5
for i in range(n):
	if abs(L - 2 * d[i][0] + 2 * d[i][1] - R) > max:
		max = abs(L - 2 * d[i][0] + 2 * d[i][1] - R)
		imax = i
if imax != -5:
	print(imax + 1)
else:
	print(0)


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

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

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

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
A = []
B = []
for _ in range(int(input())):
	(a, b) = ilele()
	A.append(a)
	B.append(b)
l = sum(A)
r = sum(B)
Ans = 0
maxi = abs(l - r)
for i in range(len(A)):
	x = A[i]
	y = B[i]
	x1 = l - x
	y1 = r - y
	x2 = x1 + y
	y2 = y1 + x
	z = abs(x2 - y2)
	if z > maxi:
		maxi = z
		Ans = i + 1
print(Ans)


n = int(input())
a = []
sl = 0
sr = 0
for i in range(n):
	(q, w) = list(map(int, input().split()))
	a += [(q, w)]
	sl += q
	sr += w
cur = abs(sr - sl)
m = 0
for i in range(n):
	if abs(sl - a[i][0] + a[i][1] - (sr - a[i][1] + a[i][0])) > cur:
		cur = abs(sl - a[i][0] + a[i][1] - (sr - a[i][1] + a[i][0]))
		m = i + 1
print(m)


n = int(input())
l = list([tuple(map(int, input().split())) for x in range(n)])
(p, q) = list(map(sum, list(zip(*l))))
o = abs(p - q)
(a, ai) = (o, 0)
for i in range(n):
	(u, v) = l[i]
	p += v - u
	q += u - v
	if abs(p - q) > a:
		(a, ai) = (abs(p - q), i + 1)
	p -= v - u
	q -= u - v
print(ai)


n = int(input())
(l, r, sl, sr, mx, a) = ([], [], 0, 0, 0, 0)
for i in range(n):
	(l1, r1) = map(int, input().split())
	l.append(l1)
	r.append(r1)
	sl += l1
	sr += r1
mx = abs(sl - sr)
for i in range(n):
	sl = abs(sl - l[i] + r[i])
	sr = abs(sr - r[i] + l[i])
	t1 = abs(sl - sr)
	if t1 > mx:
		mx = t1
		a = i + 1
	sl = abs(sl + l[i] - r[i])
	sr = abs(sr + r[i] - l[i])
print(a)


n = int(input())
s = [[int(j) for j in input().split()] for k in range(n)]
p = [sum(x) for x in zip(*s)]
q = abs(p[0] - p[1])
index = -1
for i in range(n):
	l = p[0] - s[i][0] + s[i][1]
	r = p[1] - s[i][1] + s[i][0]
	if abs(l - r) > q:
		q = abs(l - r)
		index = i
print(index + 1)


n = int(input())
a = []
(l, r) = (0, 0)
for i in range(n):
	(x, y) = map(int, input().split())
	l += x
	r += y
	a.append([x, y])
x = abs(l - r)
ind = 0
for i in range(n):
	if abs(l - a[i][0] + a[i][1] - r + a[i][1] - a[i][0]) > x:
		x = abs(l - a[i][0] + a[i][1] - r + a[i][1] - a[i][0])
		ind = i + 1
print(ind)


n = int(input())
M = [list(map(int, input().split())) for i in range(n)]
k1 = 0
k2 = 0
ma = 0
p = 0
for i in range(n):
	k1 = k1 + M[i][0]
	k2 = k2 + M[i][1]
ma = abs(k1 - k2)
for i in range(n):
	if abs(k1 - M[i][0] - (k2 - M[i][1]) - M[i][0] + M[i][1]) > ma:
		ma = abs(k1 - M[i][0] - (k2 - M[i][1]) - M[i][0] + M[i][1])
		p = i + 1
print(p)


n = int(input())
res = [0]
for i in range(n):
	(l, r) = map(int, input().split())
	res.append(l - r)
ma = max(res)
mi = min(res)
s = sum(res)
if ma + mi < s:
	print(res.index(mi))
else:
	print(res.index(ma))


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))

def solve():
	n = int(input())
	a = []
	s = 0
	t = 0
	for i in range(n):
		(p, q) = li()
		s += p
		t += q
		a.append([p, q])
	k = 0
	m = abs(s - t)
	for i in range(n):
		(p, q) = a[i]
		(h, j) = (s, t)
		h += q
		j += p
		j -= q
		h -= p
		if abs(h - j) > m:
			k = i + 1
			m = abs(j - h)
	print(k)
for _ in range(1):
	solve()


n = int(input())
k = -1
(sl, sr) = (0, 0)
l = []
for i in range(n):
	(left, right) = map(int, input().split())
	l.append((left, right))
	(sl, sr) = (sl + left, sr + right)
m = abs(sl - sr)
for i in range(n):
	(sl, sr) = (sl - l[i][0] + l[i][1], sr - l[i][1] + l[i][0])
	if abs(sl - sr) > m:
		k = i
		m = abs(sl - sr)
	(sl, sr) = (sl - (-l[i][0] + l[i][1]), sr - (-l[i][1] + l[i][0]))
print(k + 1)


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

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = []
sum_1 = 0
sum_2 = 0
for i in range(n):
	(a, b) = get_ints()
	sum_1 += a
	sum_2 += b
	Arr.append([a, b])
beauty = abs(sum_1 - sum_2)
ans = 0
for i in range(n):
	x1 = Arr[i][1] - Arr[i][0]
	x2 = Arr[i][0] - Arr[i][1]
	if abs(sum_1 + x1 - (sum_2 + x2)) > beauty:
		beauty = abs(sum_1 + x1 - (sum_2 + x2))
		ans = i + 1
print(ans)


def beauty(l, r):
	return abs(l - r)

def calcBeauty(b):
	l = 0
	r = 0
	for x in b:
		l += x[0]
		r += x[1]
	return [beauty(l, r), l, r]

def calcBigest(l, r):
	return l > r

def func():
	n = int(input())
	b = list()
	for i in range(n):
		line = input()
		l = line.split()
		b.append((int(l[0]), int(l[1])))
	bestCol = -1
	arr = calcBeauty(b)
	beauty = arr[0]
	maxBeauty = 0
	left = calcBigest(arr[1], arr[2])
	for i in range(n):
		temp = b[i][0] - b[i][1]
		if left:
			if temp > 0:
				if temp > maxBeauty and temp > beauty:
					bestCol = i
					maxBeauty = temp - beauty
			elif temp < 0:
				if abs(temp) > maxBeauty:
					bestCol = i
					maxBeauty = abs(temp)
		elif temp > 0:
			if temp > maxBeauty:
				bestCol = i
				maxBeauty = temp
		elif temp < 0:
			if abs(temp) > maxBeauty and abs(temp) > beauty:
				bestCol = i
				maxBeauty = abs(temp) - beauty
	return bestCol + 1
print(func())


n = int(input())
(l, r) = ([], [])
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	l.append(a)
	r.append(b)
(sl, sr) = (sum(l), sum(r))
score = abs(sl - sr)
maxscore = score
index = 0
for i in range(n):
	atual = abs(sl - l[i] + r[i] - (sr - r[i] + l[i]))
	if atual > maxscore:
		maxscore = atual
		index = i + 1
print(index)


import math
n = int(input())
L = 0
R = 0
LI = []
RI = []
for i in range(n):
	(a, b) = map(int, input().split())
	L += a
	R += b
	LI.append(a)
	RI.append(b)
best = math.fabs(L - R)
LT = L
RT = R
k = 0
for i in range(n):
	LT = L - LI[i] + RI[i]
	RT = R - RI[i] + LI[i]
	temp = math.fabs(LT - RT)
	if temp > best:
		k = i + 1
		best = temp
print(k)


N = int(input())
LR = []
(l, r) = (0, 0)
for n in range(N):
	(li, ri) = map(int, input().split())
	l += li
	r += ri
	LR += [[li, ri]]
cur = abs(l - r)
ind = None
for i in range(len(LR)):
	tem = abs(l - LR[i][0] * 2 - r + LR[i][1] * 2)
	if tem > cur:
		cur = tem
		ind = i + 1
if ind == None:
	print(0)
else:
	print(ind)


import math, sys, re, itertools, pprint, collections
(ri, rai) = (lambda : int(input()), lambda : list(map(int, input().split())))
n = ri()
a = [rai() for i in range(n)]
s = 0
for (l, r) in a:
	s += l - r
res = 0
sres = abs(s)
for i in range(n):
	(l, r) = a[i]
	s -= l - r
	s += r - l
	if abs(s) > sres:
		res = i + 1
		sres = abs(s)
	s -= r - l
	s += l - r
print(res)


n = int(input())
a = [0] * (n + 1)
s = 0
for i in range(1, n + 1):
	(l, r) = map(int, input().split())
	a[i] = l - r
	s += a[i]
maxx = s
q = 0
for i in range(1, n + 1):
	if abs(s - a[i] - a[i]) > abs(maxx):
		q = i
		maxx = s - a[i] - a[i]
print(q)


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
(l, r) = (sum([x[0] for x in a]), sum([x[1] for x in a]))
val = abs(l - r)
ans = 0
for (i, x) in enumerate(a):
	cur = abs(l - x[0] + x[1] - r + x[1] - x[0])
	if cur > val:
		val = cur
		ans = i + 1
print(ans)


n = int(input())
parad = [list(map(int, input().split())) for i in range(n)]
R = 0
L = 0
s = 0
for i in range(n):
	R += parad[i][1]
	L += parad[i][0]
k = abs(L - R)
max = abs(L - R)
for i in range(n):
	k = abs(L - parad[i][0] + parad[i][1] - (R - parad[i][1] + parad[i][0]))
	if k > max:
		max = k
		s = i + 1
print(s)


n = int(input())
init_f = True
min_p = max_p = -1
min_v = max_v = sum_v = 0
for i in range(n):
	(a, b) = str(input()).split()
	miss = int(a) - int(b)
	sum_v += miss
	if init_f:
		init_f = False
		min_p = max_p = i + 1
		min_v = max_v = miss
	else:
		if miss < min_v:
			(min_p, min_v) = (i + 1, miss)
		if miss > max_v:
			(max_p, max_v) = (i + 1, miss)
if max_v <= 0 or min_v >= 0:
	print(0)
elif max_v + min_v > sum_v:
	print(max_p)
else:
	print(min_p)


n = int(input())
a = n * [0]
(left_count, right_count) = (0, 0)
(cur_max, flag) = (0, 0)
for i in range(n):
	x = list(map(int, input().split()))
	a[i] = x
	left_count += x[0]
	right_count += x[1]
	if abs(x[0] - x[1]) > cur_max:
		cur_max = abs(x[0] - x[1])
mdl = abs(left_count - right_count)
for j in range(n):
	if abs(left_count - a[j][0] + a[j][1] - (right_count - a[j][1] + a[j][0])) > mdl:
		mdl = abs(left_count - a[j][0] + a[j][1] - (right_count - a[j][1] + a[j][0]))
		flag = j + 1
print(flag)


n = int(input())
l = []
r = []
c = []
for i in range(n):
	(x, y) = map(int, input().split())
	c.append([x, y])
	l.append(x)
	r.append(y)
p = sum(l)
q = sum(r)
res = abs(p - q)
chg = -1
for i in range(n):
	e = p - c[i][0]
	f = q - c[i][1]
	e += c[i][1]
	f += c[i][0]
	if abs(e - f) > res:
		chg = i
		res = abs(e - f)
print(chg + 1)


n = int(input())
bestl = 0
bestr = 0
bestsc = -1
besti = 0
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = map(int, input().split())
	bestl += l[i]
	bestr += r[i]
bestsc = abs(bestl - bestr)
for i in range(n):
	bestl -= l[i]
	bestl += r[i]
	bestr -= r[i]
	bestr += l[i]
	if abs(bestl - bestr) > bestsc:
		bestsc = abs(bestl - bestr)
		besti = i + 1
	bestl -= r[i]
	bestl += l[i]
	bestr -= l[i]
	bestr += r[i]
print(besti)


n = int(input())
(l, r) = ([], [])
for _ in range(n):
	arr = [int(x) for x in input().split()]
	l.append(arr[0])
	r.append(arr[1])
beauties = [l - r for (l, r) in zip(l, r)]
total_beauty = sum(beauties)
total_beauty_if_i_swaped = [total_beauty - 2 * x for x in beauties]
if abs(total_beauty) < abs(max(total_beauty_if_i_swaped, key=abs)):
	print(total_beauty_if_i_swaped.index(max(total_beauty_if_i_swaped, key=abs)) + 1)
else:
	print(0)


n = int(input())
(L, R) = ([], [])
(l, r) = (0, 0)
for i in range(n):
	ch = input().split()
	L.append(int(ch[0]))
	l += int(ch[0])
	r += int(ch[1])
	R.append(int(ch[1]))
be = abs(l - r)
a = 0
for i in range(n):
	if abs(l + R[i] - L[i] - (r - R[i] + L[i])) > be:
		be = abs(l + R[i] - L[i] - (r - R[i] + L[i]))
		a = i + 1
print(a)


n = int(input())
s = []
for _ in range(n):
	(l, r) = map(int, input().split())
	s.append(l - r)
osm = sum(s)
mx = osm
ans = 0
for i in range(n):
	if abs(osm - 2 * s[i]) > abs(mx):
		mx = osm - 2 * s[i]
		ans = i + 1
print(ans)


n = int(input())
a = []
b = []
for i in range(n):
	x = [int(x) for x in input().split(' ')]
	a.append(x[0])
	b.append(x[1])
sa = sum(a)
sb = sum(b)
anss = [abs(sa - sb)]
for i in range(n):
	nsa = sa - a[i] + b[i]
	nsb = sb - b[i] + a[i]
	anss.append(abs(nsa - nsb))
print(anss.index(max(anss)))


import sys
import math
import itertools
import collections

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

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

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

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

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

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

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
lb = rb = 0
p = []
for i in range(n):
	(l, r) = mi()
	p.append([l, r])
	lb += l
	rb += r
b = abs(rb - lb)
ans = 0
for i in range(n):
	tb = abs(rb - p[i][1] + p[i][0] - (lb - p[i][0] + p[i][1]))
	if tb > b:
		ans = i + 1
		b = tb
print(ans)


n = int(input())
sol = []
L = 0
R = 0
for i in range(n):
	(l, r) = map(int, input().split())
	col = [l, r]
	L += l
	R += r
	sol.append(col)
max = abs(L - R)
ans = 0
for i in range(n):
	temp_l = L - sol[i][0] + sol[i][1]
	temp_r = R - sol[i][1] + sol[i][0]
	if abs(temp_l - temp_r) > max:
		max = abs(temp_l - temp_r)
		ans = i + 1
print(ans)


arr = []
(L, R) = (0, 0)
for _ in range(int(input().strip())):
	(l, r) = map(int, input().strip().split())
	L += l
	R += r
	arr.append((l, r))
currBeauty = abs(L - R)
ans = 0
for i in range(len(arr)):
	(l, r) = arr[i]
	newL = L - l + r
	newR = R - r + l
	newBeauty = abs(newL - newR)
	if newBeauty > currBeauty:
		currBeauty = newBeauty
		ans = i + 1
print(ans)


n = int(input())
arr = list((list(map(int, input().split())) for i in range(n)))
d = [i[0] - i[1] for i in arr]
dsum = sum(d)
res = [[abs(dsum), 0]]
res += [[abs(dsum - 2 * d[i]), i + 1] for i in range(n)]
print(sorted(res, reverse=True)[0][1])


n = int(input())
larr = []
rarr = []
for i in range(n):
	yo = list(map(int, input().split()))
	larr.append(yo[0])
	rarr.append(yo[1])
l = sum(larr)
r = sum(rarr)
maxb = abs(l - r)
ans = -1
for i in range(n):
	ro = abs(l - larr[i] + rarr[i] - (r - rarr[i] + larr[i]))
	if ro > maxb:
		ans = i
		maxb = ro
print(ans + 1)


from sys import stdin, stdout
sum_left = sum_right = 0
n = int(input())
arr = stdin.readlines()
for i in arr:
	(left, right) = i.split()
	sum_left += int(left)
	sum_right += int(right)
res = 0
diff = abs(sum_left - sum_right)
for (pos, i) in enumerate(arr):
	(left, right) = i.split()
	temp_left = sum_left - int(left) + int(right)
	temp_right = sum_right - int(right) + int(left)
	if abs(temp_left - temp_right) > diff:
		diff = abs(temp_left - temp_right)
		res = pos + 1
print(res)


t = int(input())
d = []
for i in range(t):
	(l, r) = map(int, input().split())
	d.append(l - r)
if min(d) * max(d) >= 0:
	print(0)
elif abs(sum(d) - 2 * max(d)) > abs(sum(d)) and abs(sum(d) - 2 * max(d)) >= abs(sum(d) - 2 * min(d)):
	print(d.index(max(d)) + 1)
elif abs(sum(d) - 2 * min(d)) > abs(sum(d)) and abs(sum(d) - 2 * max(d)) <= abs(sum(d) - 2 * min(d)):
	print(d.index(min(d)) + 1)
else:
	print(0)


n = int(input())
c = [0] * n
L = R = 0
for i in range(n):
	(l, r) = map(int, input().split())
	c[i] = r - l
	L += l
	R += r
Max = abs(L - R)
ans = 0
for i in range(n):
	cur = abs(L - R + 2 * c[i])
	if cur > Max:
		Max = cur
		ans = i + 1
print(ans)


n = int(input())
col = []
r = 0
l = 0
for i in range(n):
	col.append([int(x) for x in input().split()])
	l += col[i][0]
	r += col[i][1]
beauty = abs(r - l)
best = -1
best_be = beauty
for i in range(n):
	(r1, l1) = col[i]
	diff = r1 - l1
	b2 = abs(r - l + 2 * diff)
	if b2 > best_be:
		best_be = b2
		best = i
print(best + 1)


n = int(input())
columns = []
(L, R) = (0, 0)
for _ in range(n):
	lr = [int(x) for x in input().split()]
	(l, r) = (lr[0], lr[1])
	columns.append((l, r))
	(L, R) = (L + l, R + r)
(beauty, ans) = (abs(L - R), -1)
for (i, (l, r)) in enumerate(columns):
	L2 = L - l + r
	R2 = R - r + l
	if abs(L2 - R2) > beauty:
		beauty = abs(L2 - R2)
		ans = i
print(ans + 1)


num = int(input())
lis = []
origin = 0
for _ in range(num):
	inp = list(map(int, input().split()))
	origin += inp[0] - inp[1]
	lis.append(inp)
ma = abs(origin)
ma_index = 0
for i in range(num):
	tmp = lis[i][1] - lis[i][0]
	su = abs(origin - (lis[i][0] - lis[i][1]) + tmp)
	if su > ma:
		ma = su
		ma_index = i + 1
print(ma_index + 0)


read = lambda : map(int, input().split())
n = int(input())
(l, r) = ([0] * n, [0] * n)
L = R = 0
for i in range(n):
	(l[i], r[i]) = read()
	L += l[i]
	R += r[i]
Max = abs(L - R)
ans = 0
for i in range(n):
	cur = abs(L - l[i] + r[i] - (R - r[i] + l[i]))
	if cur > Max:
		Max = cur
		ans = i + 1
print(ans)


n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
	(l[i], r[i]) = [int(s) for s in input().split()]
sl = sum(l)
sr = sum(r)
m = abs(sl - sr)
k = 0
for i in range(n):
	new = abs(sl - sr + 2 * r[i] - 2 * l[i])
	if new > m:
		m = new
		k = i + 1
print(k)


import math
mat = []
(neg, pos) = (0, 0)
for i in range(int(input())):
	(x, y) = map(int, input().split())
	mat.append(x - y)
for i in mat:
	if i < 0:
		neg += i
	else:
		pos += i
if pos == 0 or neg == 0:
	print(0)
else:
	print(mat.index(max(mat)) + 1 if -neg + max(mat) > pos - min(mat) else mat.index(min(mat)) + 1)


class CodeforcesTask733BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.columns = []

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

	def process_task(self):
		left = sum([x[0] for x in self.columns])
		right = sum([x[1] for x in self.columns])
		tb_basic = abs(left - right)
		mx_b = tb_basic
		chosen = 0
		for x in range(self.n):
			nl = left - self.columns[x][0]
			nr = right - self.columns[x][1]
			nb = abs(nl + self.columns[x][1] - nr - self.columns[x][0])
			if mx_b < nb:
				chosen = x + 1
				mx_b = nb
		self.result = str(chosen)

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


def get_int():
	return map(int, input().split())
n = int(input())
L = R = 0
a = []
for i in range(n):
	(x, y) = get_int()
	L += x
	R += y
	a.append((x - y, i))
m = abs(L - R)
x = 0
for i in range(n):
	if abs(L - 2 * a[i][0] - R) > m:
		m = abs(L - 2 * a[i][0] - R)
		x = a[i][1] + 1
print(x)


n = int(input())
left = []
right = []
R = 0
L = 0
for i in range(n):
	(a, b) = map(int, input().split())
	left.append(a)
	L += a
	R += b
	right.append(b)
base = abs(L - R)
m = base
cur = -1
for i in range(n):
	L1 = L - left[i] + right[i]
	R1 = R - right[i] + left[i]
	curm = abs(L1 - R1)
	if curm > m:
		m = curm
		cur = i
print(cur + 1)


def f(n, s):
	L = 0
	R = 0
	for (a, b) in s:
		L += a
		R += b
	beauty = abs(L - R)
	ind = -1
	for i in range(n):
		(a, b) = s[i]
		new = abs(L - a + b - (R - b + a))
		if new > beauty:
			ind = i
			beauty = new
	return ind + 1

def run():
	s = []
	i = 0
	for line in iter(input, ''):
		if i == 0:
			n = int(line)
		else:
			k = line.split(' ')
			m = (int(k[0]), int(k[1]))
			s.append(m)
		if i == n:
			break
		i += 1
	print(f(n, s))
run()


n = int(input())
A = []
B = []
Max1 = 0
Max2 = 0
c = 0
d = 0
Sum1 = 0
Sum2 = 0
for i in range(0, n):
	(a, b) = input().split()
	if int(a) - int(b) > Max1:
		Max1 = int(a) - int(b)
		c = i + 1
	if int(b) - int(a) > Max2:
		Max2 = int(b) - int(a)
		d = i + 1
	Sum1 = Sum1 + int(a)
	Sum2 = Sum2 + int(b)
	A.append(int(a))
	B.append(int(b))
Max = max(Max1, Max2)
if abs(Sum1 - Sum2) >= Max:
	if Sum1 >= Sum2 and Max2 > 0:
		print(d)
	elif Sum1 < Sum2 and Max1 > 0:
		print(c)
	else:
		print(0)
elif Sum1 >= Sum2:
	print(c)
else:
	print(d)


n = int(input())
l = []
r = []
d = []
L = 0
R = 0
for i in range(n):
	(tmp1, tmp2) = map(int, input().split())
	l.append(tmp1)
	r.append(tmp2)
	L += tmp1
	R += tmp2
dif = L - R
selectedDif = dif
selectedID = 0
for i in range(n):
	newDif = dif - 2 * (l[i] - r[i])
	if abs(selectedDif) < abs(newDif):
		selectedID = i + 1
		selectedDif = newDif
print(selectedID)


z = int(input())
d = []
s = []
for i in range(z):
	x = list(map(int, input().split()))
	d.append(x[0])
	s.append(x[1])
l = 0
r = 0
for i in s:
	l += i
for o in d:
	r += o
df = abs(l - r)
qa = []
for i in range(len(s)):
	a = l
	b = r
	a -= s[i]
	a += d[i]
	b -= d[i]
	b += s[i]
	qa.append(abs(a - b))
sa = qa.index(max(qa)) + 1
if max(qa) <= df:
	print(0)
else:
	print(sa)


n = int(input())
cols = []
for _ in range(n):
	(l, r) = map(int, input().split())
	cols.append((l, r))
sum_l = sum((i[0] for i in cols))
sum_r = sum((i[1] for i in cols))
dif_col = -1
beaut = abs(sum_l - sum_r)
for (idx, col) in enumerate(cols):
	b = abs(sum_l - col[0] + col[1] - (sum_r - col[1] + col[0]))
	if b > beaut:
		dif_col = idx
		beaut = b
print(dif_col + 1)


n = int(input())
ALLL = 0
ALLR = 0
MLP = 0
MRP = 0
MLPI = 0
MRPI = 0
for i in range(n):
	inp = input().split()
	L = int(inp[0])
	R = int(inp[1])
	ALLL += L
	ALLR += R
	LP = R - L
	RP = L - R
	if LP > MLP:
		MLP = LP
		MLPI = i
	if RP > MRP:
		MRP = RP
		MRPI = i
ML = ALLL - ALLR + 2 * MLP
MR = ALLR - ALLL + 2 * MRP
if ML > MR:
	if MLP == 0:
		print(0)
	else:
		print(MLPI + 1)
elif MRP == 0:
	print(0)
else:
	print(MRPI + 1)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
k = sum(a)
m = sum(b)
l = abs(k - m)
x = 0
s = 0
for i in range(n):
	if s < abs(k - m - a[i] * 2 + b[i] * 2) - l:
		x = i + 1
		s = abs(k - m - a[i] * 2 + b[i] * 2) - l
print(x)


def parade():
	no_columns = int(input())
	march_band = []
	l_value = 0
	r_value = 0
	for i in range(no_columns):
		march_band.append([int(x) for x in input().strip().split(' ')])
		l_value += march_band[i][0]
		r_value += march_band[i][1]
	max_beauty = abs(l_value - r_value)
	result = 0
	for i in range(no_columns):
		tmp_l_value = l_value - march_band[i][0] + march_band[i][1]
		tmp_r_value = r_value - march_band[i][1] + march_band[i][0]
		if max_beauty < abs(tmp_r_value - tmp_l_value):
			max_beauty = abs(tmp_r_value - tmp_l_value)
			result = i + 1
	return result
print(parade())


n = int(input())
l = []
l2 = 0
r1 = 0
for i in range(n):
	(l1, r) = list(map(int, input().split()))
	l2 += l1
	r1 += r
	l.append([l1, r])
maxim = abs(l2 - r1)
ind = -1
for i in range(n):
	s = abs(l2 - l[i][0] + l[i][1] - (r1 + l[i][0] - l[i][1]))
	if s > maxim:
		maxim = s
		ind = i
print(ind + 1)


n = int(input())
l = [0] * n
r = [0] * n
cur_res = 0
for i in range(n):
	(l[i], r[i]) = [int(x) for x in input().split()]
	cur_res += l[i] - r[i]
max_res = abs(cur_res)
max_indx = -1
for i in range(n):
	tmp_res = abs(cur_res - 2 * (l[i] - r[i]))
	if tmp_res > max_res:
		max_res = tmp_res
		max_indx = i
print(max_indx + 1)


import os
LOCAL_PC = 'n1amr' in os.path.expanduser('~')

def solve(input, print):
	n = int(input())
	pos = neg = 0
	A = [0] * n
	for i in range(n):
		(l, r) = map(int, input().split())
		A[i] = df = l - r
		if df < 0:
			neg += df
		else:
			pos += df
	beauty = abs(pos + neg)
	k = -1
	for i in range(n):
		df = A[i]
		if abs(pos + neg - 2 * df) > beauty:
			k = i
			beauty = abs(pos + neg - 2 * df)
	print(k + 1)

def process_file(in_name, out_name):
	with open(in_name, 'r') as fin:
		with open(out_name, 'w') as fout:

			def read():
				return fin.readline().rstrip('\n')

			def write(*args, end='\n'):
				text = ' '.join(map(str, args)) + end
				fout.write(text)
				print(text, end='')
			t = int(fin.readline())
			for i in range(t):
				read()
				write('Case #{T}: \n'.format(T=i + 1), end='')
				solve(read, write)
				write()

def process_stdio():

	def read():
		return input()

	def write(*args, end='\n'):
		print(*args, end=end)
	solve(read, write)
if LOCAL_PC:
	in_name = __file__[:-3] + '.in'
	out_name = __file__[:-3] + '.out'
	process_file(in_name, out_name)
else:
	process_stdio()


n = int(input())
l = []
r = []
L = 0
R = 0
d = 0
chg = 0
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
	L = L + l[i]
	R = R + r[i]
d = abs(L - R)
for i in range(n):
	if d < abs(L - l[i] + r[i] - (R - r[i] + l[i])):
		d = abs(L - l[i] + r[i] - (R - r[i] + l[i]))
		chg = i + 1
print(chg)


import sys
n = int(input())
a = [0] * (n + 1)
for i in range(n):
	(l, r) = map(int, sys.stdin.readline().split())
	a[i + 1] = l - r
	a[0] += l - r
a[1:] = [a[0] - 2 * a[i] for i in range(1, n + 1)]
a2 = [abs(i) for i in a]
ma2 = max(a2)
idx = a2.index(ma2)
print(idx)


n = int(input())
lst = []
left = 0
right = 0
for i in range(n):
	(l, r) = map(int, input().split())
	left += l
	right += r
	lst.append((l, r))
max_beaty = abs(left - right)
row = 0
for i in range(n):
	(l, r) = lst[i]
	left -= l
	left += r
	right -= r
	right += l
	if abs(left - right) > max_beaty:
		max_beaty = abs(left - right)
		row = i + 1
	left -= r
	left += l
	right -= l
	right += r
print(row)


n = int(input())
beauty_of_column = []
for i in range(0, n):
	(l, r) = [int(x) for x in input().split()]
	beauty_of_column.append(l - r)
currentBeauty = sum(beauty_of_column)
res = 0
maxBeauty = abs(currentBeauty)
for i in range(0, n):
	beauty = currentBeauty - 2 * beauty_of_column[i]
	if abs(beauty) > maxBeauty:
		maxBeauty = abs(beauty)
		res = i + 1
print(res)


import sys
fin = sys.stdin
fout = sys.stdout
results = []
n = int(fin.readline())
columns = [0] * n
allL = 0
allR = 0
for i in range(n):
	(l, r) = list(map(int, fin.readline().split()))
	columns[i] = (l, r)
	allL += l
	allR += r
results.append((abs(allL - allR), -1))
for i in range(n):
	tempL = allL
	tempR = allR
	tempL -= columns[i][0]
	tempR -= columns[i][1]
	tempL += columns[i][1]
	tempR += columns[i][0]
	results.append((abs(tempL - tempR), i))
mR = results[0][0]
mN = results[0][1]
for result in results:
	if result[0] > mR:
		mR = result[0]
		mN = result[1]
fout.write(str(mN + 1))


n = int(input())
data = []
cnt_l = 0
cnt_r = 0
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	data.append([l, r])
	cnt_l += l
	cnt_r += r
beauty = abs(cnt_l - cnt_r)
col_n = -1
max_beauty = beauty
for i in range(n):
	if abs(cnt_l - data[i][0] + data[i][1] - cnt_r + data[i][1] - data[i][0]) > max_beauty:
		col_n = i + 1
		max_beauty = abs(cnt_l - data[i][0] + data[i][1] - cnt_r + data[i][1] - data[i][0])
if col_n == -1:
	print(0)
else:
	print(col_n)


import math
import sys
n = int(input())
v = []
leftsum = 0
rightsum = 0
for i in range(n):
	v.append([int(x) for x in input().split(' ')])
	leftsum += v[i][0]
	rightsum += v[i][1]
Max = abs(leftsum - rightsum)
index = 0
for i in range(n):
	curr = abs(leftsum - v[i][0] + v[i][1] - (rightsum - v[i][1] + v[i][0]))
	if Max < curr:
		Max = curr
		index = i + 1
print(index)


n = int(input())
diff = []
for i in range(n):
	(l, r) = map(int, input().split())
	diff.append(l - r)
b = sum(diff)
i = max(range(n), key=lambda x: abs(b - 2 * diff[x]))
if abs(b - 2 * diff[i]) > abs(b):
	print(i + 1)
else:
	print(0)


n = int(input())
sum_l = 0
sum_r = 0
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	sum_l += l
	sum_r += r
	a.append([l, r])
k = abs(sum_l - sum_r)
ind = 0
for i in range(n):
	n_l = sum_l
	n_r = sum_r
	x = abs(n_l - a[i][0] + a[i][1] - (n_r - a[i][1] + a[i][0]))
	if x > k:
		k = x
		ind = i + 1
print(ind)


n = int(input())
l = []
r = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
dif = abs(sum(l) - sum(r))
y = -1
sl = sum(l)
sr = sum(r)
for i in range(n):
	if abs(sl - l[i] + r[i] - (sr - r[i] + l[i])) > dif:
		y = i
		dif = abs(sl - l[i] + r[i] - (sr - r[i] + l[i]))
print(y + 1)


n = int(input())
l = []
r = []
lsum = 0
rsum = 0
for i in range(n):
	[a, b] = list(map(int, input().split()))
	l.append(a)
	r.append(b)
	lsum += a
	rsum += b
best = abs(lsum - rsum)
besti = -1
for i in range(n):
	ls = lsum
	rs = rsum
	ls += r[i] - l[i]
	rs += l[i] - r[i]
	if best < abs(ls - rs):
		best = abs(ls - rs)
		besti = i
if besti == -1:
	print(0)
else:
	print(besti + 1)


n = int(input().strip())
ll = []
l = 0
r = 0
for i in range(n):
	u = list(map(int, input().split()))
	ll.append(u[0] - u[1])
	l += u[0]
	r += u[1]
maxx = max(ll)
minn = min(ll)
LLL = abs(l - r - 2 * minn)
RRR = abs(r + 2 * maxx - l)
if LLL >= RRR and LLL > abs(l - r):
	for i in range(n):
		if ll[i] == minn:
			print(i + 1)
			break
elif LLL < RRR and RRR > abs(l - r):
	for i in range(n):
		if ll[i] == maxx:
			print(i + 1)
			break
else:
	print(0)


n = int(input())
maxl = 0
maxr = 0
total = 0
li = 0
ri = 0
x = -1
for i in range(n):
	(l, r) = map(int, input().split())
	val = l - r
	if val < maxr:
		maxr = val
		ri = i + 1
	elif val > maxl:
		maxl = val
		li = i + 1
	total += val
if abs(total) < abs(total - 2 * maxl):
	x = li
	total = total - maxl
if abs(total) < abs(total - 2 * maxr):
	x = ri
	total = total - maxr
if x < 1:
	print('0')
else:
	print(str(x))


n = int(input())
l = []
r = []
L = 0
R = 0
for i in range(n):
	(a, b) = map(int, input().split())
	L += a
	R += b
	l.append(a)
	r.append(b)
dif = L - R
mind = dif
ans = 0
for i in range(n):
	tmp = dif + 2 * (r[i] - l[i])
	if abs(tmp) > abs(mind):
		mind = tmp
		ans = i + 1
print(ans)


a = [list(map(int, input().split())) for i in range(int(input()))]
b = [i - j for (i, j) in a]
(mn, mx) = (b.index(min(b)), b.index(max(b)))
s = sum(b)
n = abs(s)
p = abs(s - b[mn] * 2)
f = abs(s - b[mx] * 2)
print(((mx + 1, mn + 1)[p > f], (0, mn + 1)[p > n])[n > f])


n = int(input())
l = []
r = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
L = sum(l)
R = sum(r)
mx = abs(L - R)
k = 0
for i in range(n):
	Lp = L - l[i] + r[i]
	Rp = R - r[i] + l[i]
	if abs(Lp - Rp) > mx:
		mx = abs(Lp - Rp)
		k = i + 1
print(k)


n = int(input())
togetherL = 0
togetherR = 0
l = []
r = []
max = 0
for i in range(n):
	tmp = input().split()
	l.append(int(tmp[0]))
	r.append(int(tmp[1]))
	togetherL = togetherL + l[i]
	togetherR = togetherR + r[i]
mod = abs(togetherL - togetherR)
for i in range(n):
	if abs(togetherL - l[i] + r[i] - (togetherR - r[i] + l[i])) > mod:
		max = i + 1
		mod = abs(togetherL - l[i] + r[i] - (togetherR - r[i] + l[i]))
print(max)


n = int(input())
mi = 100000000
ma = -100000000
sum = 0
minI = -1
maxI = -1
for i in range(n):
	raw = input().split()
	l = int(raw[0])
	r = int(raw[1])
	dif = l - r
	if mi > dif:
		mi = dif
		minI = i
	if ma < dif:
		ma = dif
		maxI = i
	sum += dif
i = 0
lsum = sum - 2 * mi
rsum = sum - 2 * ma
sum = abs(sum)
lsum = abs(lsum)
rsum = abs(rsum)
if sum >= max(lsum, rsum):
	print(0)
	quit()
if lsum > rsum:
	print(minI + 1)
else:
	print(maxI + 1)


__author__ = 'Think'
n = int(input())
total = 0
diffmax = -500
maxi = -1
mini = -1
diffmin = 500
for i in range(n):
	(l, r) = [int(i) for i in input().split()]
	diff = l - r
	if diff > diffmax:
		maxi = i
		diffmax = diff
	if diff < diffmin:
		mini = i
		diffmin = diff
	total += diff
if abs(total - 2 * diffmax) > abs(total - 2 * diffmin):
	if abs(total - 2 * diffmax) > abs(total):
		print(maxi + 1)
	else:
		print(0)
elif abs(total - 2 * diffmin) > abs(total):
	print(mini + 1)
else:
	print(0)


n = int(input())
lr = [list(map(int, input().split())) for i in range(n)]
d = [i[0] - i[1] for i in lr]
dsum = sum(d)
poss = [[abs(dsum), 0]] + [[abs(dsum - 2 * d[i]), i + 1] for i in range(n)]
print(sorted(poss, reverse=1)[0][1])


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
diff = [x[0] - x[1] for x in a]
s = sum(diff)
num = s
res = 0
for i in range(n):
	if abs(s - 2 * diff[i]) > abs(num):
		res = i + 1
		num = s - 2 * diff[i]
print(res)


n = int(input())
(l, r, diff) = ([], [], [])
ans = 0
for i in range(n):
	(li, ri) = map(int, input().split())
	l.append(li)
	r.append(ri)
	diff.append(li - ri)
lSum = sum(l)
rSum = sum(r)
currentDiff = abs(lSum - rSum)
pos1 = diff.index(max(diff))
pos2 = diff.index(min(diff))
diff1 = abs(lSum - max(diff) - rSum - max(diff))
diff2 = abs(lSum - min(diff) - rSum - min(diff))
if currentDiff >= diff1 and currentDiff >= diff2:
	ans = 0
elif diff1 > currentDiff and diff1 > diff2:
	ans = pos1 + 1
else:
	ans = pos2 + 1
print(ans)


from copy import deepcopy

def f(n, m):
	return abs(n - m)
n = int(input())
mas = []
L = 0
R = 0
for i in range(n):
	(l, r) = map(int, input().split())
	mas.append((l, r))
	L += l
	R += r
sum = f(L, R)
old = deepcopy(sum)
new = deepcopy(old)
for i in range(n):
	L -= mas[i][0]
	R -= mas[i][1]
	L += mas[i][1]
	R += mas[i][0]
	if f(L, R) > new:
		ans = i
		new = f(L, R)
	L -= mas[i][1]
	R -= mas[i][0]
	L += mas[i][0]
	R += mas[i][1]
if new - old == 0:
	print(0)
else:
	print(ans + 1)


n = int(input())
ar = [list(map(int, input().split())) for x in range(n)]
L = 0
R = 0
for (l, r) in ar:
	L += l
	R += r
best = abs(L - R)
ans = 0
i = 1
for (l, r) in ar:
	L -= l
	L += r
	R -= r
	R += l
	if abs(L - R) > best:
		best = abs(L - R)
		ans = i
	L += l
	L -= r
	R += r
	R -= l
	i += 1
print(ans)


n = int(input())
dif = []
left_sum = 0
right_sum = 0
for i in range(n):
	(l_val, r_val) = (int(ch_num) for ch_num in input().split(' '))
	left_sum += l_val
	right_sum += r_val
	dif.append(l_val - r_val)
index = 0
max_mark = abs(left_sum - right_sum)
for i in range(n):
	new_mark = abs(left_sum - dif[i] - (right_sum + dif[i]))
	if new_mark > max_mark:
		index = i + 1
		max_mark = new_mark
print(index)


n = int(input())
ans = 0
l = 0
r = 0
ml = 0
mr = 0
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append((x, y))
	l += x
	r += y
best = abs(l - r)
c = 0
new = 0
for v in a:
	c += 1
	nl = l
	nr = r
	nl = nl - v[0] + v[1]
	nr = nr - v[1] + v[0]
	if abs(nl - nr) > best:
		new = c
		best = abs(nl - nr)
print(new)


n = [sum(map(int, ('-' + input()).split())) for i in range(int(input()))]
(s, a, b) = (sum(n), min(n), max(n))
if abs(s + a * -2) > abs(s) and abs(s + a * -2) > abs(s + b * -2):
	print(n.index(a) + 1)
elif abs(s + b * -2) > abs(s):
	print(n.index(b) + 1)
else:
	print(0)


import math
l = 0
r = 0
n = int(input())
max = -1
j = 0
x = 0
y = 0
str2 = []
for i in range(n):
	str1 = input().split()
	str2.append(str1)
	l += int(str1[0])
	r += int(str1[1])
max = abs(l - r)
for i in range(n):
	if abs(l - int(str2[i][0]) + int(str2[i][1]) - (r + int(str2[i][0]) - int(str2[i][1]))) > max:
		max = abs(l - int(str2[i][0]) + int(str2[i][1]) - (r + int(str2[i][0]) - int(str2[i][1])))
		j = i + 1
if j == 0:
	print(0)
else:
	print(j)


n = int(input())
L = []
sum_l = 0
sum_r = 0
for i in range(n):
	(l, r) = map(int, input().split())
	L.append((l, r))
	sum_l += l
	sum_r += r
krasa = abs(sum_l - sum_r)
ans = 0
for i in range(n):
	if abs(sum_l - L[i][0] + L[i][1] - (sum_r - L[i][1] + L[i][0])) > krasa:
		krasa = abs(sum_l - L[i][0] + L[i][1] - (sum_r - L[i][1] + L[i][0]))
		ans = i + 1
print(ans)


r = lambda : map(int, input().split())
n = int(input())
l = []
for x in range(n):
	(a, b) = r()
	l.append(a - b)
s = sum(l)
new = [abs(s - 2 * x) for x in l]
m = max(new)
if abs(s) >= m:
	print(0)
else:
	print(new.index(m) + 1)


n = int(input())
(a, b) = ([], [])
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
sa = sum(a)
sb = sum(b)
d = abs(sa - sb)
i = 0
for j in range(n):
	_d = abs(sa + b[j] - a[j] - (sb + a[j] - b[j]))
	if _d > d:
		d = _d
		i = j + 1
print(i)


n = int(input())
L = []
R = []
for _ in range(n):
	(a, b) = map(int, input().split())
	L.append(a)
	R.append(b)
Lb = sum(L)
Rb = sum(R)
ind = -1
beauty = abs(Rb - Lb)
for i in range(n):
	if abs(Lb - L[i] + R[i] - (Rb - R[i] + L[i])) > beauty:
		beauty = abs(Lb - L[i] + R[i] - (Rb - R[i] + L[i]))
		ind = i
print(ind + 1)


n = int(input())
l = []
r = []
max_lr = 0
max_lr_index = -1
max_rl = 0
max_rl_index = -1
for i in range(n):
	lr = list(map(int, input().split()))
	l.append(lr[0])
	r.append(lr[1])
	if lr[0] - lr[1] > max_lr:
		max_lr = lr[0] - lr[1]
		max_lr_index = i
	if lr[1] - lr[0] > max_rl:
		max_rl = lr[1] - lr[0]
		max_rl_index = i
if sum(l) + max_rl > sum(r) + max_lr:
	print(max_rl_index + 1)
else:
	print(max_lr_index + 1)


import sys
from math import *
input = sys.stdin.buffer.readline
t = int(input())
max_r = 0
max_l = 0
total_r = 0
total_l = 0
col_pos1 = 0
col_pos2 = 0
for i in range(t):
	(l, r) = map(int, input().split())
	total_l += l
	total_r += r
	if l < r:
		if max_r < r - l:
			max_r = r - l
			col_pos2 = i + 1
	elif max_l < l - r:
		max_l = l - r
		col_pos1 = i + 1
ans = int(fabs(total_r - total_l))
ans1 = int(fabs(total_r - max_r - (total_l + max_r)))
ans2 = int(fabs(total_r + max_l - (total_l - max_l)))
if ans >= ans1 and ans >= ans2:
	print('0')
elif ans1 >= ans and ans1 >= ans2:
	print(col_pos2)
else:
	print(col_pos1)


n = int(input())
couples = []
for i in range(n):
	co = input()
	co = co.split()
	co = list(map(int, co))
	couples.append(co)
(l, r) = (0, 0)
for i in couples:
	l += i[0]
	r += i[1]
c = 0
dif = abs(l - r)
index = -1
for i in couples:
	(l_n, r_n) = (l - i[0] + i[1], r - i[1] + i[0])
	dif_n = abs(l_n - r_n)
	if dif_n > dif:
		dif = dif_n
		index = c
	c += 1
print(index + 1)


n = int(input())
L = [0] * n
R = [0] * n
for i in range(n):
	(L[i], R[i]) = map(int, input().split())
ll = sum(L)
rr = sum(R)
a = ll - rr
s = []
m = abs(a)
p = 0
b = False
for i in range(n):
	s.append(a + 2 * R[i] - 2 * L[i])
	if abs(s[i]) > abs(m):
		m = abs(s[i])
		p = i
		b = True
if not b:
	print(0)
else:
	print(p + 1)


n = int(input())
ls = []
rs = []
for i in range(n):
	(l, r) = [int(x) for x in input().split()]
	ls.append(l)
	rs.append(r)
lss = sum(ls)
rss = sum(rs)
best = abs(lss - rss)
ans = None
for i in range(n):
	lss1 = lss - ls[i] + rs[i]
	rss1 = rss - rs[i] + ls[i]
	if abs(lss1 - rss1) > best:
		best = abs(lss1 - rss1)
		ans = i
print(0 if ans is None else ans + 1)


def main():
	try:
		while True:
			n = int(input())
			left = [0] * n
			right = [0] * n
			for i in range(n):
				(left[i], right[i]) = map(int, input().split())
			ls = sum(left)
			rs = sum(right)
			best = abs(ls - rs)
			result = -1
			for (i, (cl, cr)) in enumerate(zip(left, right)):
				cur = abs(ls - cl + cr - (rs - cr + cl))
				if cur > best:
					best = cur
					result = i
			print(result + 1)
	except EOFError:
		pass
main()


n = int(input())
left = []
right = []
dif1 = []
dif2 = []
total = []
for i in range(n):
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(r)
	if l > r:
		dif1.append((abs(l - r), i))
	else:
		dif2.append((abs(l - r), i))
total.append((abs(sum(left) - sum(right)), 0))
try:
	(left[max(dif1)[1]], right[max(dif1)[1]]) = (right[max(dif1)[1]], left[max(dif1)[1]])
	total.append((abs(sum(left) - sum(right)), max(dif1)[1] + 1))
	(left[max(dif1)[1]], right[max(dif1)[1]]) = (right[max(dif1)[1]], left[max(dif1)[1]])
except:
	pass
try:
	(left[max(dif2)[1]], right[max(dif2)[1]]) = (right[max(dif2)[1]], left[max(dif2)[1]])
	total.append((abs(sum(left) - sum(right)), max(dif2)[1] + 1))
	(left[max(dif2)[1]], right[max(dif2)[1]]) = (right[max(dif2)[1]], left[max(dif2)[1]])
except:
	pass
print(max(total)[1])


n = int(input())
(a, b) = (list(), list())
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
ll1 = sum(a)
rr1 = sum(b)
res = abs(ll1 - rr1)
ans = 0
for i in range(n):
	ll = ll1
	rr = rr1
	ll -= a[i]
	ll += b[i]
	rr -= b[i]
	rr += a[i]
	if res < abs(ll - rr):
		ans = i + 1
		res = abs(ll - rr)
print(ans)


import sys
import math
import bisect

def solve(A, B):
	n = len(A)
	sum_a = sum(A)
	sum_b = sum(B)
	max_val = abs(sum_a - sum_b)
	sol = 0
	for i in range(n):
		tmp_a = sum_a - A[i] + B[i]
		tmp_b = sum_b - B[i] + A[i]
		val = abs(tmp_a - tmp_b)
		if max_val < val:
			max_val = val
			sol = i + 1
	return sol

def main():
	n = int(input())
	A = []
	B = []
	for i in range(n):
		(a, b) = map(int, input().split())
		A.append(a)
		B.append(b)
	ans = solve(A, B)
	print(ans)
main()


n = int(input())
left = []
right = []
for i in range(n):
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(r)
x = sum(left)
y = sum(right)
k = 0
t = 0
for i in range(n):
	p = left[i]
	q = right[i]
	if abs(x - y + 2 * (q - p)) > abs(x - y) and abs(x - y + 2 * (q - p)) - abs(x - y) > t:
		t = abs(x - y + 2 * (q - p)) - abs(x - y)
		k = i + 1
print(k)


t = int(input(''))
q = 0
s = 0
e = 0
f = 0
b = 0
c = 0
x = 0
g = 0
r = 0
j = 0
r1 = 0
q1 = 0
u = 0
y = 0
a1 = 0
a2 = 0
for z in range(0, t):
	a = list(map(int, input().split()))
	b += a[0]
	c += a[1]
	if a[0] - a[1] > 0:
		if a[0] - a[1] > a1:
			q = a[0]
			u = z
			q1 = a[1]
			a1 = a[0] - a[1]
	if a[1] - a[0] > 0:
		if a[1] - a[0] > a2:
			x = z
			r = a[0]
			r1 = a[1]
			a2 = a[1] - a[0]
e = abs(b - c)
h = abs(b - q + q1 - (c - q1 + q))
t = abs(b - r + r1 - (c - r1 + r))
qwe = max(e, h, t)
kl = {e: 0, h: u + 1, t: x + 1}
if qwe == e:
	print('0')
else:
	print(kl[qwe])


n = int(input())
(L, R) = (0, 0)
a = []
for i in range(n):
	(li, ri) = map(int, input().split())
	a.append([li, ri])
	L += li
	R += ri
ans = abs(L - R)
ansi = 0
for i in range(n):
	l1 = L - a[i][0] + a[i][1]
	r1 = R - a[i][1] + a[i][0]
	if abs(l1 - r1) > ans:
		ans = abs(l1 - r1)
		ansi = i + 1
print(ansi)


n = int(input())
l = 0
r = 0
l1 = 0
l2 = 0
r1 = 0
r2 = 0
maxd1 = 0
maxd2 = 0
k1 = 0
k2 = 0
for i in range(n):
	(a, b) = map(int, input().split())
	l = l + a
	r = r + b
	if a > b and abs(a - b) > maxd1:
		l1 = a
		r1 = b
		maxd1 = abs(a - b)
		k1 = i + 1
	if b > a and abs(a - b) > maxd2:
		l2 = a
		r2 = b
		maxd2 = abs(a - b)
		k2 = i + 1
if abs(l - r) < abs(l - l2 + r2 - (r - r2 + l2)) and abs(l - l1 + r1 - (r - r1 + l1)) <= abs(l - l2 + r2 - (r - r2 + l2)):
	print(k2)
elif abs(l - r) < abs(l - l1 + r1 - (r - r1 + l1)) and abs(l - l2 + r2 - (r - r2 + l2)) <= abs(l - l1 + r1 - (r - r1 + l1)):
	print(k1)
else:
	print(0)


n = int(input())
sl = []
sr = []
index = 0
for i in range(n):
	(l, r) = list(map(int, input().split()))
	sl.append(l)
	sr.append(r)
NICE = sum(sl) - sum(sr)
mnice = abs(NICE)
if NICE > 0:
	for j in range(n):
		e = abs(NICE - sl[j] * 2 + sr[j] * 2)
		if e > mnice:
			index = j + 1
			mnice = e
elif NICE < 0:
	for k in range(n):
		e = abs(NICE - sl[k] * 2 + sr[k] * 2)
		if e > mnice:
			index = k + 1
			mnice = e
else:
	for z in range(n):
		e = abs(sl[z] * 2 - sr[z] * 2)
		if NICE + e > mnice:
			index = z + 1
			mnice = e
print(index)


n = int(input())
L = 0
R = 0
p = []
for i in range(n):
	(a, b) = map(int, input().split(' '))
	p.append((a, b))
	L += a
	R += b
res = abs(L - R)
res_i = 0
for i in range(n):
	if res < abs(L - p[i][0] + p[i][1] - (R - p[i][1] + p[i][0])):
		res = abs(L - p[i][0] + p[i][1] - (R - p[i][1] + p[i][0]))
		res_i = 1 + i
print(res_i)


n = int(input())
(l, r) = (0, 0)
a = []
for i in range(n):
	(l_i, r_i) = map(int, input().split())
	l += l_i
	r += r_i
	a.append([l_i, r_i])
ans = abs(l - r)
ind = 0
for i in range(n):
	if abs(l - a[i][0] + a[i][1] - (r - a[i][1] + a[i][0])) > ans:
		ans = abs(l - a[i][0] + a[i][1] - (r - a[i][1] + a[i][0]))
		ind = i + 1
print(ind)


n = [0] + [sum(map(int, ('-' + input()).split())) for i in range(int(input()))]
(s, a, b) = (sum(n), min(n), max(n))
print(n.index(b if s < a + b else a))


columns = int(input(''))
values = []
(ltotal, rtotal) = (0, 0)
for i in range(0, columns):
	(l, r) = map(int, input('').split(' '))
	values.append((l, r))
	ltotal += l
	rtotal += r
oldBeauty = abs(ltotal - rtotal)
beauty = []
for i in range(0, columns):
	(l, r) = values[i]
	new_ltotal = ltotal - l + r
	new_rtotal = rtotal - r + l
	beauty.append(abs(new_ltotal - new_rtotal))
toChange = 0
diff = 0
for i in range(0, columns):
	if beauty[i] > oldBeauty and beauty[i] - oldBeauty > diff:
		toChange = i + 1
		diff = beauty[i] - oldBeauty
print(toChange)


n = int(input())
z = 0
a = []
(x, y) = (0, 0)
for i in range(n):
	(l, r) = map(int, input().split())
	a.append((l, r))
	x += l
	y += r
m = abs(x - y)
for i in range(n):
	k = abs(x - a[i][0] + a[i][1] - (y - a[i][1] + a[i][0]))
	if k > m:
		z = i + 1
		m = k
print(z)


import math
n = int(input())
mylist = []
for i in range(n):
	mylist.append([int(j) for j in input().split()])
mL = 0
mR = 0
for i in range(len(mylist)):
	mL += mylist[i][0]
	mR += mylist[i][1]
beauty = math.floor(math.fabs(mL - mR))
s = 0
for i in range(len(mylist)):
	L = mL
	R = mR
	L -= mylist[i][0]
	R -= mylist[i][1]
	L += mylist[i][1]
	R += mylist[i][0]
	new = math.fabs(L - R)
	if new > beauty:
		s = i + 1
		beauty = new
print(s)


a = []
b = []
sum1 = 0
sum2 = 0
maxsum = 0
k = 0
for i in range(int(input())):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
	sum1 += x
	sum2 += y
maxsum = abs(sum1 - sum2)
for i in range(len(a)):
	sum1 = sum1 - a[i] + b[i]
	sum2 = sum2 - b[i] + a[i]
	if abs(sum1 - sum2) > maxsum:
		k = i + 1
		maxsum = abs(sum1 - sum2)
	sum1 = sum1 - b[i] + a[i]
	sum2 = sum2 - a[i] + b[i]
print(k)


n = int(input())
L = 0
R = 0
t = [[0, 0] for i in range(n)]
for i in range(n):
	(a, b) = map(int, input().split())
	L += a
	R += b
	t[i][0] = a
	t[i][1] = b
maxx = abs(L - R)
ind = 0
for i in range(n):
	j = t[i][0]
	k = t[i][1]
	B = abs(L - j + k - (R - k + j))
	if B > maxx:
		maxx = B
		ind = i + 1
print(ind)


N = int(input())
mxld = 0
mxli = -1
mxrd = 0
mxri = -1
sml = 0
smr = 0
for n in range(1, N + 1):
	(l, r) = [int(n) for n in input().split()]
	diff = r - l
	if diff > mxrd:
		mxrd = diff
		mxri = n
	if diff < mxld:
		mxld = diff
		mxli = n
	sml += l
	smr += r
mxdiff = abs(sml - smr)
i = 0
if mxrd > 0:
	diff = abs(sml + mxrd - (smr - mxrd))
	if mxdiff < diff:
		mxdiff = diff
		i = mxri
if mxld < 0:
	diff = abs(sml + mxld - (smr - mxld))
	if mxdiff < diff:
		mxdiff = diff
		i = mxli
print(i)


from sys import stdin, stdout
n = int(stdin.readline())
challengers = []
(l, r) = (0, 0)
for i in range(n):
	(a, b) = map(int, stdin.readline().split())
	challengers.append((a, b))
	l += a
	r += b
ans = abs(r - l)
label = 0
for i in range(n):
	(a, b) = challengers[i]
	if abs(r - b + a - (l - a + b)) > ans:
		ans = abs(r - b + a - (l - a + b))
		label = i + 1
if label:
	stdout.write(str(label))
else:
	stdout.write('0')


n = int(input())
j = k = 0
s = 0
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	if x >= y:
		j += 1
	if y >= x:
		k += 1
	a.append(x)
	b.append(y)
	s += x - y
if j == n or k == n:
	print(0)
	exit(0)
z = s
max = abs(s)
for i in range(n):
	s += 2 * (b[i] - a[i])
	if max < abs(s):
		ans = i + 1
		max = abs(s)
	s = z
print(ans)


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
n = ii()
(a, b) = zip(*(map(int, input().split()) for _ in range(n)))
asm = sum(a)
bsm = sum(b)
c = [abs(asm - bsm)]
for (i, j) in zip(a, b):
	c.append(abs(asm + j - i - (bsm + i - j)))
print(c.index(max(c)))


def f(l):
	ab = lambda x: x if x > 0 else -x
	k = len(l)
	dl = [c[0] - c[1] for c in l]
	ss = sum(dl)
	mb = ab(ss)
	mi = 0
	for i in range(k):
		b = ab(ss - (dl[i] << 1))
		if b > mb:
			mi = i + 1
			mb = b
	return mi
k = int(input())
l = [list(map(int, input().split())) for _ in range(k)]
print(f(l))


n = int(input())
(l, r) = (0, 0)
dif = []
res = 0
for i in range(n):
	(x, y) = map(int, input().split())
	dif.append(x - y)
	l = l + x
	r = r + y
a = l - r
c = a
for i in range(n):
	b = a - 2 * dif[i]
	if abs(b) > abs(c):
		res = i + 1
		c = b
print(res)


n = int(input())
D = [0] * n
for i in range(n):
	(l, r) = map(int, input().split())
	D[i] = l - r
(beauty, min_d, max_d) = (sum(D), min(D), max(D))
print(max((beauty, 0), (beauty - 2 * min_d, D.index(min_d) + 1), (beauty - 2 * max_d, D.index(max_d) + 1), key=lambda data: abs(data[0]))[1])


n = int(input())
a = []
lsum = 0
rsum = 0
i = 0
while i < n:
	(l, r) = map(int, input().split())
	a.append((l, r))
	lsum += l
	rsum += r
	i += 1
ans = 0
cur = abs(lsum - rsum)
i = 0
while i < n:
	lsum -= a[i][0]
	rsum -= a[i][1]
	lsum += a[i][1]
	rsum += a[i][0]
	if cur < abs(lsum - rsum):
		cur = abs(lsum - rsum)
		ans = i + 1
	lsum -= a[i][1]
	rsum -= a[i][0]
	lsum += a[i][0]
	rsum += a[i][1]
	i += 1
print(ans)


import sys
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
n = I()
nl = []
for i in range(n):
	nl.append(li())
s = [0, 0]
for i in nl:
	s[0] += i[0]
	s[1] += i[1]
m = abs(s[0] - s[1])
ans = -1
for i in range(n):
	t1 = s[0] + nl[i][1] - nl[i][0]
	t2 = s[1] + nl[i][0] - nl[i][1]
	diff = abs(t1 - t2)
	if diff > m:
		m = diff
		ans = i
print(ans + 1)


n = int(input())
count = [0, 0]
A = []
index = 0
good = False
for i in range(n):
	(l, r) = map(int, input().split())
	count[0] += l
	count[1] += r
	A.append((l, r))
beuty = abs(count[0] - count[1])
for i in range(n):
	if abs(count[0] + (A[i][1] - A[i][0]) - (count[1] + (A[i][0] - A[i][1]))) > beuty:
		good = True
		index = i + 1
		beuty = abs(count[0] + (A[i][1] - A[i][0]) - (count[1] + (A[i][0] - A[i][1])))
if good:
	print(index)
else:
	print(0)


n = int(input())
a = []
l = r = 0
for i in range(n):
	a.append(list(map(int, input().split())))
	l += a[-1][0]
	r += a[-1][1]
mi = abs(l - r)
res = 0
(L, R) = (l, r)
for i in range(n):
	l -= a[i][0]
	r += a[i][0]
	r -= a[i][1]
	l += a[i][1]
	if abs(l - r) > mi:
		res = i + 1
		mi = abs(l - r)
	l = L
	r = R
print(res)


n = int(input())
l = []
(lft, rgt) = (0, 0)
for i in range(n):
	l.append(list(map(int, input().split())))
	lft += l[i][0]
	rgt += l[i][1]
beauty = abs(lft - rgt)
mxbeauty = beauty
ans = 0
for i in range(n):
	if mxbeauty < abs(lft - l[i][0] + l[i][1] - (rgt - l[i][1] + l[i][0])):
		mxbeauty = abs(lft - l[i][0] + l[i][1] - (rgt - l[i][1] + l[i][0]))
		ans = i + 1
print(ans)


n = int(input())
A = [0] * n
B = [0] * n
l = 0
r = 0
for i in range(n):
	(A[i], B[i]) = list(map(int, input().split()))
	l += B[i]
	r += A[i]
m = abs(l - r)
ic = 0
for i in range(n):
	rc = r - A[i] + B[i]
	lc = l + A[i] - B[i]
	mc = abs(rc - lc)
	if mc > m:
		ic = i + 1
		m = mc
print(ic)


n = int(input())
delta = []
L = 0
R = 0
for nn in range(n):
	(l, r) = [int(x) for x in input().split()]
	delta.append(l - r)
	L += l
	R += r
s = L + R
m = 0
mi = 0
for (i, d) in enumerate(delta):
	dL = L - d
	dR = R + d
	if m < abs(dL - dR):
		mi = i
		m = abs(dL - dR)
if m < abs(L - R):
	print(0)
	exit()
print(mi + 1)


n = int(input())
a = []
ans = 0
(L, R) = (0, 0)
for i in range(n):
	t = input().split()
	L += int(t[0])
	R += int(t[1])
	a.append(t)
Max = abs(L - R)
for i in range(n):
	l = L - int(a[i][0]) + int(a[i][1])
	r = R - int(a[i][1]) + int(a[i][0])
	if abs(l - r) > Max:
		Max = abs(l - r)
		ans = i + 1
print(ans)


n = int(input())
parade = []
for k in range(n):
	x = tuple(map(int, input().split()))
	parade.append(x)
l = 0
r = 0
for i in parade:
	l += i[0]
	r += i[1]
beauty = abs(l - r)

def change(i):
	return abs(l - r + 2 * (parade[i][1] - parade[i][0]))
(k, m) = (0, beauty)
for i in range(len(parade)):
	if change(i) > m:
		(k, m) = (i, change(i))
if m == beauty:
	print(0)
else:
	print(k + 1)


import math
n = int(input())
buff = []
for i in range(n):
	(a, b) = map(int, input().strip().split())
	buff.append(a - b)
answ = 0
for i in range(n):
	answ += buff[i]
answ = math.fabs(answ)
l = 0
k = 0
mi = buff.index(min(buff))
ma = buff.index(max(buff))
buff[mi] = -1 * buff[mi]
for i in range(n):
	k += buff[i]
k = math.fabs(k)
if k > answ:
	answ = k
	l = mi + 1
buff[mi] = buff[mi] * -1
buff[ma] = -1 * buff[ma]
k = 0
for i in range(n):
	k += buff[i]
k = math.fabs(k)
if k > answ:
	answ = k
	l = ma + 1
print(l)


n = int(input())
(l, r) = ([], [])
(L, R) = (0, 0)
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
	(L, R) = (L + x, R + y)
(ans, newL, newR) = (0, L, R)
for (i, (x, y)) in enumerate(zip(l, r)):
	if abs(L - x + y - (R - y + x)) > abs(newL - newR):
		newL = L - x + y
		newR = R - y + x
		ans = i + 1
if ans > 0 and abs(newL - newR) > abs(L - R):
	print(ans)
else:
	print(0)


import sys
n = int(sys.stdin.readline())
mp = [None] * n
l = r = 0
for i in range(n):
	mp[i] = list(map(int, sys.stdin.readline().split()))
	l += mp[i][0]
	r += mp[i][1]
	dif = abs(l - r)
	res = int(0)
for i in range(n):
	_l = l - mp[i][0] + mp[i][1]
	_r = r - mp[i][1] + mp[i][0]
	_dif = abs(_l - _r)
	if _dif > dif:
		dif = _dif
		res = i + 1
print(res)


n = int(input())
m = []
for i in range(n):
	g = list(map(int, input().split()))
	m.append(g)
l = 0
r = 0
for i in range(n):
	l += m[i][0]
	r += m[i][1]
beauty = abs(l - r)
ans = 0
for i in range(n):
	x = l - m[i][0] + m[i][1]
	y = r - m[i][1] + m[i][0]
	a = abs(x - y)
	if a > beauty:
		beauty = a
		ans = i + 1
print(ans)


N = int(input())
L = 0
R = 0
lLegs = []
rLegs = []
for i in range(N):
	(l, r) = [int(x) for x in input().strip().split(' ')]
	L += l
	R += r
	lLegs.append(l)
	rLegs.append(r)
score = abs(L - R)
best = -1
for i in range(N):
	if abs(L - lLegs[i] + rLegs[i] - (R - rLegs[i] + lLegs[i])) > score:
		best = i
		score = abs(L - lLegs[i] + rLegs[i] - (R - rLegs[i] + lLegs[i]))
print(best + 1)


c = [(0, 0)] + [list(map(int, input().split())) for _ in range(int(input()))]
d = list(zip(*c))
L = sum(d[0])
R = sum(d[1])
ans = [abs(L - R - (x[0] - x[1]) * 2) for (i, x) in enumerate(c, 1)]
print(ans.index(max(ans)))


N = int(input())
Groups = []
(Left, Right, CurrentMax, Index) = (0, 0, 0, 0)
for i in range(N):
	Groups.append(list(map(int, input().split())))
	(Left, Right) = (Left + Groups[i][0], Right + Groups[i][1])
CurrentMax = abs(Left - Right)
for i in range(N):
	Temp = abs(Left + Groups[i][1] - Groups[i][0] - (Right + Groups[i][0] - Groups[i][1]))
	if Temp > CurrentMax:
		CurrentMax = Temp
		Index = i + 1
print(Index)


import sys
n = int(input())
a = []
b = []
p = 0
q = 0
for i in range(n):
	x = list(input().split(' '))
	a.append(int(x[0]))
	b.append(int(x[1]))
	p += int(x[0])
	q += int(x[1])
min = abs(p - q)
j = 0
for i in range(n):
	if abs(p - q - 2 * a[i] + 2 * b[i]) > min:
		min = abs(p - q - 2 * a[i] + 2 * b[i])
		j = i + 1
print(j)


t = int(input())
(l, r) = ([], [])
(c1, c2) = (0, 0)
for i in range(t):
	(a, b) = map(int, input().split())
	l.append(a)
	r.append(b)
	c1 += a
	c2 += b
c = abs(c1 - c2)
d = 0
n = c
for i in range(t):
	e = abs(c1 - l[i] + r[i] - (c2 - r[i] + l[i]))
	if e > n:
		d = i + 1
		n = e
print(d)


def parade():
	n = int(input())
	L = []
	R = []
	for i in range(n):
		(a, b) = map(int, input().strip().split())
		L.append(a)
		R.append(b)
	Lsum = sum(L)
	Rsum = sum(R)
	Max_beauty = abs(Lsum - Rsum)
	id = 0
	for i in range(n):
		a = L[i]
		b = R[i]
		kmax = abs(Lsum - a + b - (Rsum - b + a))
		if kmax > Max_beauty:
			Max_beauty = kmax
			id = i + 1
	print(id)
parade()


n = int(input())
(left, right) = ([], [])
L = R = 0
for _ in range(n):
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(r)
	L += l
	R += r
(max_k, max_i) = (abs(L - R), -1)
for i in range(n):
	Li = L - left[i] + right[i]
	Ri = R - right[i] + left[i]
	k = abs(Li - Ri)
	if k > max_k:
		(max_k, max_i) = (k, i)
print(max_i + 1)


def parad(l, r):
	(s1, s2) = (sum(l), sum(r))
	(ans, ch) = (abs(s1 - s2), 0)
	for i in range(len(l)):
		z = abs(s1 - l[i] + r[i] - (s2 - r[i] + l[i]))
		if z > ans:
			(ans, ch) = (z, i + 1)
	return ch
n = int(input())
(L, R) = (list(), list())
for j in range(n):
	(s, t) = [int(x) for x in input().split()]
	L.append(s)
	R.append(t)
print(parad(L, R))


n = int(input())
w = [list(map(int, input().split())) for i in range(n)]
(p, q) = (0, 0)
for i in w:
	p += i[0]
	q += i[1]
ans = -1
max1 = abs(p - q)
for i in range(n):
	r = abs(p - w[i][0] + w[i][1] - (q - w[i][1] + w[i][0]))
	if max1 < r:
		max1 = r
		ans = i
print(ans + 1)


n = int(input())
arr = [tuple(map(int, input().split())) for i in range(n)]
(sl, sr) = (0, 0)
for h in arr:
	sl += h[0]
	sr += h[1]
(mx, a, i) = (abs(sl - sr), -1, 0)
for h in arr:
	si = abs(sl - h[0] + h[1] - (sr - h[1] + h[0]))
	if si > mx:
		(mx, a) = (si, i)
	i += 1
print(a + 1)


import sys
cols = sys.stdin.readline()
cols = cols.strip().replace('\n', '')
cols = int(cols)
leftright = []
for i in range(0, cols):
	a = sys.stdin.readline().strip().replace('\n', '')
	leftright.append(a.split(' '))
maxLoverR = 0
loc1 = 0
maxRoverL = 0
loc2 = 0
count = 0
leftTotal = 0
rightTotal = 0
for i in leftright:
	if int(i[0]) - int(i[1]) > maxLoverR:
		maxLoverR = int(i[0]) - int(i[1])
		loc1 = count
	if int(i[1]) - int(i[0]) > maxRoverL:
		maxRoverL = int(i[1]) - int(i[0])
		loc2 = count
	leftTotal = leftTotal + int(i[0])
	rightTotal = rightTotal + int(i[1])
	count += 1
currentBeauty = abs(leftTotal - rightTotal)
temp = leftTotal - int(leftright[loc1][0])
temp2 = rightTotal - int(leftright[loc1][1])
temp += int(leftright[loc1][1])
temp2 += int(leftright[loc1][0])
change = 0
if abs(temp2 - temp) > currentBeauty:
	currentBeauty = abs(temp2 - temp)
	change = loc1 + 1
temp = leftTotal - int(leftright[loc2][0])
temp2 = rightTotal - int(leftright[loc2][1])
temp += int(leftright[loc2][1])
temp2 += int(leftright[loc2][0])
if abs(temp2 - temp) > currentBeauty:
	currentBeauty = abs(temp2 - temp)
	change = loc2 + 1
print(change)


n = int(input())
le = 0
ri = 0
a = [0] * n
b = [0] * n
no = -21
for i in range(n):
	(l, r) = map(int, input().split())
	le = le + l
	ri = ri + r
	a[i] = l
	b[i] = r
v = abs(le - ri)
for i in range(n):
	l1 = le - a[i] + b[i]
	r1 = ri - b[i] + a[i]
	x = abs(l1 - r1)
	if x > v:
		no = i
		v = x
if no == -21:
	print(0)
else:
	print(no + 1)


n = int(input())
Q = []
q = 0
for i in range(n):
	(l, r) = map(int, input().split())
	Q.append([l - r, i + 1])
	q += l - r
Q.sort()
a = abs(q)
b = abs(q - 2 * Q[0][0])
c = abs(q - 2 * Q[-1][0])
if a >= b and a >= c:
	print(0)
elif b > c:
	print(Q[0][1])
else:
	print(Q[-1][1])


n = int(input())
x = []
for _ in range(n):
	i = list(map(int, input().split()))
	x.append(i[0] - i[1])
if all((i >= 0 for i in x)) or all((i <= 0 for i in x)):
	print(0)
else:
	m = [a for a in x if a > 0]
	n = [b for b in x if b < 0]
	if len(n) == 1:
		print(x.index(n[0]) + 1)
	elif len(m) == 1:
		print(x.index(m[0]) + 1)
	elif sum(m) - max(m) <= -sum(n):
		print(x.index(max(m)) + 1)
	else:
		print(x.index(min(n)) + 1)


n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
B = []
l = 0
r = 0
for i in range(n):
	l += A[i][0]
	r += A[i][1]
a = abs(l - r)
B.append(a)
for j in range(n):
	if A[j][0] > A[j][1]:
		li = A[j][0] - A[j][1]
		ln = l - li
		rn = r + li
		a = abs(ln - rn)
		B.append(a)
	else:
		ri = A[j][1] - A[j][0]
		ln = l + ri
		rn = r - ri
		a = abs(ln - rn)
		B.append(a)
print(B.index(max(B)))


numbers = []
L = 0
R = 0

def getMaxBeauty():
	global numbers, L, R
	maximo = abs(L - R)
	column = 0
	flag = False
	for i in range(0, n):
		dif = numbers[i][1] - numbers[i][0]
		beauty = abs(L + dif - (R - dif))
		if beauty > maximo:
			maximo = beauty
			column = i
			flag = True
	if flag:
		return column + 1
	return 0
n = int(input())
for _ in range(0, n):
	tupla = tuple(map(int, input().split()))
	numbers.append(tupla)
	L += tupla[0]
	R += tupla[1]
print(getMaxBeauty())


n = int(input())
l = []
r = []
(L, R) = (0, 0)
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
	L += x
	R += y
now = abs(L - R)
res = 0
for i in range(n):
	x = L
	y = R
	x -= l[i]
	x += r[i]
	y -= r[i]
	y += l[i]
	if abs(x - y) > now:
		now = abs(x - y)
		res = i + 1
print(res)


n = int(input())
Tot_x = 0
Tot_y = 0
MaxL = 0
MinL = 99999999
MaxL_pos = 0
MinL_pos = 0
MaxR = 0
MinR = 99999999
MaxR_pos = 0
MinR_pos = 0
for i in range(n):
	(x, y) = map(int, input().split())
	Tot_x += x
	Tot_y += y
	Lx = x - y
	if Lx > MaxL:
		MaxL = Lx
		MaxL_pos = i + 1
	if Lx < MinL:
		MinL = Lx
		MinL_pos = i + 1
	Lx = y - x
	if Lx > MaxR:
		MaxR = Lx
		MaxR_pos = i + 1
	if Lx < MinR:
		MinR = Lx
		MinR_pos = i + 1
Max = abs(Tot_x - Tot_y)
mi = Max
dist = 0
if Tot_x > Tot_y:
	if Max < abs(mi + 2 * MaxR):
		Max = abs(mi + 2 * MaxR)
		dist = MaxR_pos
	if Max < abs(mi + 2 * MinR):
		Max = abs(mi + 2 * MinR)
		dist = MinR_pos
	print(dist)
else:
	if Max < abs(mi + 2 * MaxL):
		Max = abs(mi + 2 * MaxL)
		dist = MaxL_pos
	if Max < abs(mi + 2 * MinL):
		Max = abs(mi + 2 * MinL)
		dist = MinL_pos
	print(dist)


def get_data():
	output = [[0, 0]]
	n = int(input())
	for i in range(n):
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		output[0][0] += a
		output[0][1] += b
		output.append([a, b])
	return output
data = get_data()

def check_beauty():
	diff = abs(data[0][0] - data[0][1])
	counter = 0
	max_i = 0
	for i in range(1, len(data)):
		a = data[0][0] - data[i][0]
		b = data[0][1] - data[i][1]
		c = a + data[i][1]
		d = b + data[i][0]
		gain = abs(c - d)
		if gain > diff and gain > counter:
			counter = gain
			max_i = i
	return max_i
answer = check_beauty()
print(answer)


n = int(input())
hold = []
l = 0
r = 0
for i in range(n):
	(a, b) = map(int, input().split())
	l += a
	r += b
	hold.append([a, b])
beauty = abs(l - r)
new_beauty = 0
col = 0
for i in range(n):
	a = hold[i][0]
	b = hold[i][1]
	t_l = l - a + b
	t_r = r - b + a
	new_beauty = abs(t_l - t_r)
	if new_beauty > beauty:
		col = i + 1
		beauty = new_beauty
print(col)


n = int(input())
LR = [list(map(int, input().split())) for _ in range(n)]
suml = sum((LR[i][0] for i in range(n)))
sumr = sum((LR[i][1] for i in range(n)))
sgn = lambda x: x // abs(x) if x != 0 else 0
resb = [abs(suml - sumr + 2 * (LR[i][1] - LR[i][0])) for i in range(n)]
maxind = 0
for i in range(1, n):
	if resb[maxind] < resb[i]:
		maxind = i
print(maxind + 1 if resb[maxind] > abs(suml - sumr) else 0)


from sys import exit
n = int(input())
R = 0
L = 0
mr = (0, 0)
ml = (0, 0)
for i in range(1, n + 1):
	(li, ri) = (int(_) for _ in input().split())
	R += ri
	L += li
	if ri > li:
		mr = max(mr, (ri - li, i))
	elif li > ri:
		ml = max(ml, (li - ri, i))
if R + ml[0] > L + mr[0]:
	print(ml[1])
elif R + ml[0] < L + mr[0]:
	print(mr[1])
else:
	print(ml[1])


from sys import stdin as fin
n = int(fin.readline())
(l, r) = ([None] * n, [None] * n)
ls = rs = 0
for i in range(n):
	(l[i], r[i]) = map(int, fin.readline().strip().split())
	ls += l[i]
	rs += r[i]
maxv = abs(ls - rs)
maxi = None
for i in range(n):
	nabs = abs(ls - l[i] + r[i] - (rs - r[i] + l[i]))
	if nabs > maxv:
		maxv = nabs
		maxi = i
print(maxi + 1 if maxi is not None else 0)


n = int(input())
a = []
r = 0
l = 0
for i in range(n):
	(x, y) = [int(j) for j in input().split()]
	l += x
	r += y
	a.append([x, y])
mk = abs(l - r)
ind = 0
for i in range(n):
	k = abs(l - a[i][0] + a[i][1] - (r - a[i][1] + a[i][0]))
	if k > mk:
		mk = k
		ind = i + 1
print(ind)


n = int(input())
li = []
ri = []
l_sum = 0
r_sum = 0
for i in range(n):
	(a, b) = map(int, input().split())
	li.append(a)
	ri.append(b)
	l_sum += a
	r_sum += b
j = -1
diff = abs(l_sum - r_sum)
for i in range(n):
	m = abs(l_sum - li[i] + ri[i] - (r_sum - ri[i] + li[i]))
	if m > diff:
		j = i
		diff = m
print(j + 1)


s = int(input())
temp1 = []
temp2 = []
suma = []
suma2 = []
total1 = 0
total2 = 0
lado = 0
rango = int(s)

def sumarLista(lista):
	a = 0
	for i in range(0, len(lista)):
		a = a + int(lista[i])
	return a
for i in range(0, rango):
	if i < rango:
		num = input()
		num = num.split(' ')
		temp1.insert(i, num[0])
		total1 = total1 + int(num[0])
		temp2.insert(i, num[1])
		total2 = total2 + int(num[1])
if total2 >= total1:
	mayor = total2
else:
	mayor = total1
for i in range(0, rango):
	if i < rango:
		if int(temp2[i]) < int(temp1[i]):
			suma.insert(i, total2 - int(temp2[i]) + int(temp1[i]))
		else:
			suma.insert(i, total2)
	if i < rango:
		if int(temp1[i]) < int(temp2[i]):
			suma2.insert(i, total1 - int(temp1[i]) + int(temp2[i]))
		else:
			suma2.insert(i, total1)
columna = 0
for i in range(0, rango):
	if i < rango:
		if mayor < int(suma[i]):
			mayor = suma[i]
			columna = i + 1
		if mayor < int(suma2[i]):
			mayor = suma2[i]
			columna = i + 1
print(columna)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
c = 0
b = l[0][0] < l[0][1]
for i in range(n):
	if (l[i][0] < l[i][1]) != b:
		c = 1
		break
if c == 0:
	print(0)
else:
	sl = 0
	sr = 0
	for i in range(n):
		sl += l[i][0]
		sr += l[i][1]
	d = {}
	for i in range(n):
		a = sl
		b = sr
		a += -l[i][0] + l[i][1]
		b += l[i][0] - l[i][1]
		d[abs(a - b)] = i + 1
	print(d[max(d.keys())])


n = int(input())
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a += [x - y]
ans = 0
val = sum(a)
mvl = abs(val)
for i in range(n):
	tmp = abs(val - a[i] * 2)
	if mvl < tmp:
		mvl = tmp
		ans = i + 1
print(ans)


a = []
for i in range(int(input())):
	a.append(list(map(int, input().split())))
k = [0, 0]
for j in a:
	k[0] += j[0]
	k[1] += j[1]
k1 = abs(k[0] - k[1])
maxi = -1
maxd = k1
for l in range(len(a)):
	(a[l][0], a[l][1]) = (a[l][1], a[l][0])
	k2 = [k[0] - a[l][1] + a[l][0], k[1] - a[l][0] + a[l][1]]
	k1 = abs(k2[0] - k2[1])
	if k1 > maxd:
		maxi = l
		maxd = k1
	(a[l][0], a[l][1]) = (a[l][1], a[l][0])
print(maxi + 1)


n = int(input())
columns = [list(map(int, input().split())) for i in range(n)]
difference_of_columns = [columns[i][0] - columns[i][1] for i in range(n)]
min_beauty = max_beauty = difference_of_columns[0]
min_beauty_index = max_beauty_index = 0
for i in range(n):
	if difference_of_columns[i] > max_beauty:
		max_beauty = difference_of_columns[i]
		max_beauty_index = i
	elif difference_of_columns[i] < min_beauty:
		min_beauty = difference_of_columns[i]
		min_beauty_index = i
difference_of_parade = sum(difference_of_columns)
beauty = abs(difference_of_parade)
new_beauty_with_min = abs(difference_of_parade - 2 * min_beauty)
new_beauty_with_max = abs(difference_of_parade - 2 * max_beauty)
if new_beauty_with_max > beauty:
	if new_beauty_with_min > new_beauty_with_max:
		print(min_beauty_index + 1)
	else:
		print(max_beauty_index + 1)
elif new_beauty_with_min > beauty:
	print(min_beauty_index + 1)
else:
	print(0)


l = [0] + [eval('-'.join(input().split())) for _ in range(int(input()))]
print(l.index([max(l), min(l)][max(l) + min(l) < sum(l)]))


n = int(input())
X = []
Y = []
Tot_x = 0
Tot_y = 0
for i in range(n):
	(x, y) = map(int, input().split())
	X.append(x)
	Tot_x += x
	Y.append(y)
	Tot_y += y
Mi = abs(Tot_x - Tot_y)
Max = Mi
dist = 0
for i in range(n):
	if Max < abs(Tot_y - Tot_x + 2 * (X[i] - Y[i])):
		Max = abs(Tot_y - Tot_x + 2 * (X[i] - Y[i]))
		dist = i + 1
print(dist)


A = [-1 * sum(map(int, ('-' + input()).split())) for _ in range(int(input()))]
(s, mx, mn) = (sum(A), max(A), min(A))
print(0 if mn > 0 or mx < 0 else A.index(mn) + 1 if s - mn - mx > 0 else A.index(mx) + 1)


n = int(input())
pairs = []
L = 0
R = 0
for i in range(n):
	pair = input().split(' ')
	L += int(pair[0])
	R += int(pair[1])
	pairs.append((int(pair[0]), int(pair[1]), i + 1))
pairs.sort(key=lambda x: abs(L - R + 2 * (x[1] - x[0])))
if abs(L - R + 2 * (pairs[-1][1] - pairs[-1][0])) <= abs(L - R):
	print(0)
else:
	print(pairs[-1][2])


n = int(input())
a = []
sumi = 0
left_big = 0
left_big_index = -1
right_big = 0
right_big_index = -1
for i in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
	difference = x - y
	sumi += difference
	if difference > 0:
		if difference > left_big:
			left_big = difference
			left_big_index = i
	elif abs(difference) > right_big:
		right_big = abs(difference)
		right_big_index = i
sum_l = sumi + 2 * right_big
sum_r = abs(sumi - 2 * left_big)
sumi = abs(sumi)
mx = max(sumi, sum_r, sum_l)
if mx == sum_l:
	print(right_big_index + 1)
elif mx == sum_r:
	print(left_big_index + 1)
else:
	print(0)


n = int(input(''))
a = []
b = []
l = 0
r = 0
z = -1
for i in range(n):
	a.append([int(j) for j in input().split()])
	l = l + a[i][0]
	r = r + a[i][1]
	b.append(a[i][0] - a[i][1])
p = max(l, r)
for i in range(len(b)):
	if b[i] < 0:
		if l + abs(b[i]) > p:
			p = l + abs(b[i])
			z = i
	elif b[i] > 0:
		if r + b[i] > p:
			p = r + b[i]
			z = i
if z < 0:
	print(0)
else:
	print(z + 1)


n = int(input())
l = []
(le, ri) = (0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	le += a
	ri += b
	l.append([a, b])
ma = le - ri
z = []
t = ma
for i in range(n):
	t = t - 2 * l[i][0] + 2 * l[i][1]
	z.append(abs(t))
	t = ma
if max(z) > abs(ma):
	print(z.index(max(z)) + 1)
else:
	print(0)


n = int(input())
l = []
r = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	r.append(y)
r1 = sum(l)
r2 = sum(r)
v = abs(r1 - r2)
s = 0
for i in range(n):
	k = abs(r1 - l[i] + r[i] - (r2 - r[i] + l[i]))
	if k > v:
		v = k
		s = i + 1
print(s)


N = int(input())
L = []
R = []
for i in range(N):
	(l, r) = map(int, input().split())
	L.append(l)
	R.append(r)
lsum = sum(L)
rsum = sum(R)
ans = abs(lsum - rsum)
ansi = 0
for i in range(N):
	nlsum = lsum - L[i] + R[i]
	nrsum = rsum - R[i] + L[i]
	nans = abs(nlsum - nrsum)
	if nans > ans:
		ansi = i + 1
		ans = nans
print(ansi)


n = int(input())
l = []
r = []
for _ in range(n):
	(l_, r_) = list(map(int, input().split()))
	l.append(l_)
	r.append(r_)
L = sum(l)
R = sum(r)
mx = abs(L - R)
sol = -1
for i in range(n):
	mxt = abs(L - R - 2 * l[i] + 2 * r[i])
	if mxt > mx:
		mx = mxt
		sol = i
if sol == -1:
	print(0)
else:
	print(sol + 1)


a = int(input())
lx = []
ly = []
for i in range(a):
	(x, y) = map(int, input().split())
	lx.append(x)
	ly.append(y)
dist = 0
mn = abs(sum(lx) - sum(ly))
op = sum(lx)
up = sum(ly)
for i in range(a):
	if abs(op - lx[i] + ly[i] - (up - ly[i] + lx[i])) > mn:
		mn = abs(op - lx[i] + ly[i] - (up - ly[i] + lx[i]))
		dist = i + 1
print(dist)