#include <bits/stdc++.h>
using namespace std;
double xa[1000], ya[1000], xb[1000], yb[1000], cx[1000], cy[1000], z[1000];
int safe(double x, double a, double b) {
  if (x >= a && x <= b) return 1;
  return 0;
}
int main() {
  int n, m;
  int i, j;
  while (scanf("%d", &n) != -1) {
    int f = 1, s = 0;
    for (i = 0; i < n; i++) {
      scanf("%lf%lf%lf%lf", &xa[i], &ya[i], &xb[i], &yb[i]);
      double t;
      if (xa[i] > xb[i]) t = xa[i], xa[i] = xb[i], xb[i] = t;
      if (ya[i] > yb[i]) t = ya[i], ya[i] = yb[i], yb[i] = t;
      z[i] = pow((xb[i] - xa[i]), 3.0);
      cx[i] = (xa[i] + xb[i]) / 2;
      cy[i] = (ya[i] + yb[i]) / 2;
    }
    double x, y, w;
    for (i = 1; i < n; i++) {
      x = cx[i], y = cy[i], w = z[i];
      for (j = i - 1; j >= 0; j--) {
        if (safe(x, xa[j], xb[j]) && safe(y, ya[j], yb[j])) {
        } else
          break;
        x = (w * x + z[j] * cx[j]) / (w + z[j]);
        y = (w * y + z[j] * cy[j]) / (w + z[j]);
        w += z[j];
      }
      if (j >= 0) break;
    }
    printf("%d\n", i);
  }
  return 0;
}
