#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1;
const int MAXM = 1;
const int MAXK = 1;
struct rect {
  double x, y, x1, x2, y1, y2;
  int m;
};
int n, X1, X2, Y1, Y2, ans;
rect rects[101];
int main() {
  scanf("%d", &n);
  for (int i = 0, _n = (n); i < _n; i++) {
    scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
    if (X1 > X2) swap(X1, X2);
    if (Y1 > Y2) swap(Y1, Y2);
    rects[i].x1 = X1;
    rects[i].x2 = X2;
    rects[i].y1 = Y1;
    rects[i].y2 = Y2;
    rects[i].m = (X2 - X1) * (X2 - X1) * (X2 - X1);
    rects[i].x = double(X1 + X2) / 2;
    rects[i].y = double(Y1 + Y2) / 2;
  }
  for (int i = 0, _n = (n); i < _n; i++) {
    double curX = rects[i].x, curY = rects[i].y;
    int curM = rects[i].m;
    for (int j = (i), _b = (1); j >= _b; j--) {
      curX = (curX * curM + rects[j].x * rects[j].m) / (curM + rects[j].m);
      curY = (curY * curM + rects[j].y * rects[j].m) / (curM + rects[j].m);
      if (!(rects[j - 1].x1 <= curX && curX <= rects[j - 1].x2 &&
            rects[j - 1].y1 <= curY && curY <= rects[j - 1].y2)) {
        printf("%d\n", i);
        exit(0);
      }
      curM += rects[j].m * (j != i);
    }
  }
  printf("%d\n", n);
  return 0;
}
