#include <bits/stdc++.h>
const double EPS = 1e-8;
struct Node {
  int x1, y1, x2, y2;
  double x, y;
  int s;
  void read() {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x = (x1 + x2) * 0.5;
    y = (y1 + y2) * 0.5;
    s = x2 - x1;
    if (s < 0) s = -s;
  }
};
Node a[128];
int n;
bool check(int k) {
  for (int i = k; i > 0; i--) {
    double x = 0;
    double y = 0;
    int s = 0;
    for (int j = k; j >= i; j--) {
      x += a[j].x * a[j].s * a[j].s * a[j].s;
      y += a[j].y * a[j].s * a[j].s * a[j].s;
      s += a[j].s * a[j].s * a[j].s;
    }
    x /= s;
    y /= s;
    if (x + EPS < a[i - 1].x1 && x + EPS < a[i - 1].x2) return false;
    if (y + EPS < a[i - 1].y1 && y + EPS < a[i - 1].y2) return false;
    if (x - EPS > a[i - 1].x1 && x - EPS > a[i - 1].x2) return false;
    if (y - EPS > a[i - 1].y1 && y - EPS > a[i - 1].y2) return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) a[i].read();
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (check(i))
      ans = i + 1;
    else
      break;
  }
  printf("%d\n", ans);
  return 0;
}
