#include <bits/stdc++.h>
using namespace std;
long long n, sumr, suml, cr, cl, mr, ml, p;
int main() {
  int ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    suml += a;
    sumr += b;
    if (a - b > cl) cl = a - b, ml = i;
    if (b - a > cr) cr = b - a, mr = i;
  }
  if (suml < sumr) {
    if (sumr - suml + 2 * cl <= suml + 2 * cr - sumr)
      printf("%d", mr), p = 1;
    else if (cl)
      printf("%d", ml), p = 1;
  }
  if (suml > sumr) {
    if (suml - sumr + 2 * cr <= sumr + 2 * cl - suml)
      printf("%d", ml), p = 1;
    else if (cr)
      printf("%d", mr), p = 1;
  }
  if (suml == sumr) {
    if (cl >= cr && cl) printf("%d", ml), p = 1;
    if (cl < cr && cr) printf("%d", mr), p = 1;
  }
  if (!p) printf("0");
  return 0;
}
