4499: 游行

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:9 通过:5

题目描述

  很快,伯兰将举行一场战胜外星入侵者的游行。不幸的是,所有士兵都在战争中丧生,现在军队由全新的新兵组成,其中许多人甚至不知道他们应该从哪条腿开始行军。平民也不太了解新兵从哪条腿开始行军,因此有多少士兵步调一致才重要。
将有n个纵队参加阅兵,第i纵队由从左腿开始行军的黎族士兵和从右腿开始行军的里兵组成。

  阅兵的美感由以下公式计算:如果L是阅兵中从左腿开始行进的士兵总数,R是阅兵队伍中从右腿开始行进的士兵总数,那么美感将等于|L-R|。

  你可以选择一列,并告诉这个纵队中的所有士兵切换起始腿,即这个纵队中从左腿开始行军的每个人现在将从右腿开始行军,反之亦然。正式地,您可以选择不超过一个索引 i 并交换值 li 和 ri。
找到柱子的索引,这样切换其中士兵的起跑腿将最大限度地提高阅兵的美感,或者确定,没有这样的操作可以增加当前的美感。



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 li soldiers, who start to march from left leg, and ri 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 li and ri.
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≤105)− the number of columns.
The next n lines contain the pairs of integers li and ri (1≤li,ri≤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.


输入格式

第一行包含单个整数 n (1≤n≤105)− 列数。
接下来的 n 行包含整数对 li 和 ri (1≤li,ri≤500)− 第 i 列中分别从左腿或右腿开始行进的士兵人数。

输出格式

打印单个整数 k− 士兵需要改变他们开始行军的腿的列数,如果已经达到最大美感,则为 0。
考虑列按照它们在输入数据中的给定顺序从 1 到 n 进行编号。
如果有多个答案,请打印其中任何一个。

输入样例 复制

3
5 6
8 9
10 3

输出样例 复制

3

数据范围与提示

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
在第一个示例中,如果您不下达改变腿的命令,则从左腿开始行军的士兵人数将等于 5+8+10=23,从右腿开始  6+9+3=18。在这种情况下,游行的美感将等于|23-18|=5。
如果你下令将腿改为第三纵队,那么从左腿行进的士兵人数将等于 5+8+3=16,从右腿行进的士兵人数 − 6+9+10=25。在这种情况下,美感等于|16-25|=9。
通过下达另一个命令不可能达到更大的美感。因此,可以实现的最大美感是9。