#include <bits/stdc++.h>
int main() {
  static int vv[100], x0[100], x1[100], y0[100], y1[100];
  static long long xx[100], yy[100];
  int n, m, p, tmp, a, i, stable;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x0[i], &y0[i], &x1[i], &y1[i]);
    x0[i] *= 2, y0[i] *= 2, x1[i] *= 2, y1[i] *= 2;
    if (x0[i] > x1[i]) tmp = x0[i], x0[i] = x1[i], x1[i] = tmp;
    if (y0[i] > y1[i]) tmp = y0[i], y0[i] = y1[i], y1[i] = tmp;
    a = (x1[i] - x0[i]) / 2;
    vv[i] = a * a * a;
    xx[i] = (x0[i] + x1[i]) / 2 * vv[i];
    yy[i] = (y0[i] + y1[i]) / 2 * vv[i];
  }
  for (i = 1; i < n; i++) {
    vv[i] += vv[i - 1];
    xx[i] += xx[i - 1];
    yy[i] += yy[i - 1];
  }
  for (m = 2; m <= n; m++) {
    stable = 1;
    for (p = 1; p < m; p++) {
      int v = vv[m - 1] - vv[p - 1];
      long long x = xx[m - 1] - xx[p - 1];
      long long y = yy[m - 1] - yy[p - 1];
      if (x < (long long)x0[p - 1] * v || x > (long long)x1[p - 1] * v ||
          y < (long long)y0[p - 1] * v || y > (long long)y1[p - 1] * v) {
        stable = 0;
        break;
      }
    }
    if (!stable) break;
  }
  printf("%d\n", m - 1);
  return 0;
}
