#include <bits/stdc++.h>
using namespace std;
void ASS(bool b) {
  if (!b) ++*(int*)0;
}
#pragma comment(linker, "/STACK:106777216")
struct P {
  double x, y;
  P() {}
  P(double xx, double yy) {
    x = xx;
    y = yy;
  }
};
int Cmp(double x, double y) {
  if (fabs(x - y) < 1e-9) return 0;
  if (x < y)
    return -1;
  else
    return 1;
}
struct C {
  int x0, y0;
  int x1, y1;
  void read() {
    int xx0, yy0;
    int xx1, yy1;
    scanf("%d %d", &xx0, &yy0);
    scanf("%d %d", &xx1, &yy1);
    x0 = min(xx0, xx1);
    x1 = max(xx0, xx1);
    y0 = min(yy0, yy1);
    y1 = max(yy0, yy1);
  }
  int V() { return (x1 - x0) * (x1 - x0) * (x1 - x0); }
  P Cent() { return P((x0 + x1) / 2.0, (y0 + y1) / 2.0); }
  bool Cont(P p) {
    return Cmp(x0, p.x) <= 0 && Cmp(p.x, x1) <= 0 && Cmp(y0, p.y) <= 0 &&
           Cmp(p.y, y1) <= 0;
  }
};
C c[110];
bool Ok(int k) {
  for (int i = 2; i <= k; i++) {
    P cent = P(0, 0);
    double mass = 0;
    for (int j = i; j <= k; j++) {
      P cc = c[j].Cent();
      cent.x += cc.x * c[j].V();
      cent.y += cc.y * c[j].V();
      mass += c[j].V();
    }
    cent.x /= mass;
    cent.y /= mass;
    if (!c[i - 1].Cont(cent)) return 0;
  }
  return 1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) c[i + 1].read();
  int k = 1;
  while (k < n && Ok(k + 1)) k++;
  printf("%d\n", k);
  return 0;
}
