-----Problem-----

Suppose there is a circle. There are N Juice shops on that circle. Juice shops are numbered 0 to N-1 (both inclusive). You have two pieces of information corresponding to each of the juice shop:
(1) the amount of Juice that a particular Juice shop can provide and 
(2) the distance from that juice shop to the next juice shop.

Initially, there is a man with a bottle of infinite capacity carrying no juice. He can start the tour at any of the juice shops. Calculate the first point from where the man will be able to complete the circle. Consider that the man will stop at every Juice Shop. The man will move one kilometer for each litre of the juice.

-----Input-----
- 
The first line will contain the value of N.
				
- 
The next N lines will contain a pair of integers each, i.e. the amount of juice that a juice shop can provide(in litres) and the distance between that juice shop and the next juice shop.
				

-----Output-----

An integer which will be the smallest index of the juice shop from which he can start the tour.
		

-----Constraints-----
- 
					1 ≤ N ≤ 105
- 
					1 ≤ amt of juice, distance  ≤ 109

-----Sample Input-----
3

1 5

10 3

3 4

-----Sample Output-----
1

-----Explanation-----

			He can start the tour from the SECOND Juice shop.
		 p { text-align:justify }

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
import re, sys

def isCirlePossible(juices, distances):
	if juices == [] or distances == []:
		return -1
	total_juice_consumed = 0
	juice_consumed = 0
	start = 0
	for i in range(0, len(juices)):
		diff = juices[i] - distances[i]
		if juice_consumed >= 0:
			juice_consumed += diff
		else:
			juice_consumed = diff
			start = i
		total_juice_consumed += diff
	return start
juices = []
distances = []
numLines = int(input())
for each in range(0, numLines):
	line = input()
	result = [int(x) for x in re.findall('\\d+', line)]
	if len(result) == 2:
		juices.append(result[0])
		distances.append(result[1])
print(isCirlePossible(juices, distances))
return


import random
T = int(input().strip())
try:
	a = 0
	ans = None
	for t in range(T):
		(j, d) = list(map(int, input().strip().split()))
		a += j
		a -= d
		if ans is None:
			ans = t
		if a <= 0:
			a = 0
			ans = None
	if ans is None:
		print(0)
	else:
		print(ans)
except:
	print(ans)


a = 0
ans = None
for t in range(int(input().strip())):
	(j, d) = list(map(int, input().strip().split()))
	a += j
	a -= d
	if ans is None:
		ans = t
	if a <= 0:
		a = 0
		ans = None
if ans is None:
	print(0)
else:
	print(ans)


N = int(input())
station = [0] * (N + 1)
for i in range(N):
	(amount, distance) = list(map(int, input().split()))
	station[i] = (amount, distance)
for c in range(N):
	i = c
	p = station[i][0]
	while i < c + N and p >= station[i % N][1]:
		p += station[(i + 1) % N][0] - station[i % N][1]
		i += 1
	if i == c + N:
		break
	c = i + 1
print(c)