#include <bits/stdc++.h>
int main(void) {
  int i, j, n, t, m, mn;
  int x1[111], y1[111], x2[111], y2[111], xm, ym;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &x1[i], &y1[i], &x2[i], &y2[i]);
    if (x1[i] > x2[i]) t = x1[i], x1[i] = x2[i], x2[i] = t;
    if (y1[i] > y2[i]) t = y1[i], y1[i] = y2[i], y2[i] = t;
    m = (x2[i] - x1[i]) * (x2[i] - x1[i]) * (x2[i] - x1[i]);
    xm = (x1[i] + x2[i]) * m;
    ym = (y1[i] + y2[i]) * m;
    for (j = i - 1; j >= 0; j--) {
      if ((xm < m * 2 * x1[j]) || (xm > m * 2 * x2[j]) ||
          (ym < m * 2 * y1[j]) || (ym > m * 2 * y2[j])) {
        printf("%d\n", i);
        return 0;
      }
      mn = (x2[j] - x1[j]) * (x2[j] - x1[j]) * (x2[j] - x1[j]);
      xm = xm + mn * (x1[j] + x2[j]);
      ym = ym + mn * (y1[j] + y2[j]);
      m += mn;
    }
  }
  printf("%d\n", n);
  return 0;
}
