#include <bits/stdc++.h>
using namespace std;
double X1[100], Y1[100], X2[100], Y2[100], M[100];
int n;
bool is_in(double f, double t, double w) {
  return (min(f, t) - 1E-9 <= w && w <= max(f, t) + 1E-9);
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%lf%lf%lf%lf", &X1[i], &Y1[i], &X2[i], &Y2[i]);
    if (X1[i] > X2[i]) swap(X1[i], X2[i]);
    if (Y1[i] > Y2[i]) swap(Y1[i], Y2[i]);
    M[i] = abs(pow(X1[i] - X2[i], 3.0));
    double SX = 0, SY = 0, SM = 0;
    for (j = i; j >= 0; --j) {
      SM += M[j];
      SX += ((X1[j] + X2[j]) / 2) * M[j];
      SY += ((Y1[j] + Y2[j]) / 2) * M[j];
      if (!is_in(max(X1[j], (j == 0) ? X1[j] : X1[j - 1]),
                 min(X2[j], (j == 0) ? X2[j] : X2[j - 1]), SX / SM) ||
          !is_in(max(Y1[j], (j == 0) ? Y1[j] : Y1[j - 1]),
                 min(Y2[j], (j == 0) ? Y2[j] : Y2[j - 1]), SY / SM))
        break;
    }
    if (j >= 0) {
      printf("%d\n", i);
      i = -1;
      break;
    }
  }
  if (i != -1) printf("%d\n", n);
  return 0;
}
