#include <bits/stdc++.h>
double x1[1010], x2[1010], y11[1010], y2[1010];
double cubic(double x) { return x * x * x; }
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++)
      scanf("%lf%lf%lf%lf", &x1[i], &y11[i], &x2[i], &y2[i]);
    bool find = false;
    for (int i = 0; i < n; i++) {
      bool ok = true;
      for (int j = 0; j < i; j++) {
        double tx = 0, ty = 0, tm = 0;
        for (int k = j + 1; k <= i; k++) {
          double tnum = cubic(fabs(x2[k] - x1[k]));
          tx += (x1[k] + x2[k]) * tnum;
          ty += (y11[k] + y2[k]) * tnum;
          tm += tnum;
        }
        tx /= tm;
        ty /= tm;
        if (!(fabs(tx - x1[j] - x2[j]) <= fabs(x2[j] - x1[j]) &&
              fabs(ty - y11[j] - y2[j]) <= fabs(x2[j] - x1[j])))
          ok = false;
      }
      if (!ok) {
        printf("%d\n", i);
        find = true;
        break;
      }
    }
    if (!find) printf("%d\n", n);
  }
  return 0;
}
