#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
};
bool pointInRect(double gx, double gy, rect r) {
  if (!(gx >= (double)r.x1 && gx <= (double)r.x2)) return false;
  if (!(gy >= (double)r.y1 && gy <= (double)r.y2)) return false;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  rect rs[128];
  int i;
  for (i = 0; i < n; ++i) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    rs[i].x1 = min(x1, x2);
    rs[i].y1 = min(y1, y2);
    rs[i].x2 = max(x1, x2);
    rs[i].y2 = max(y1, y2);
    long long xsum = 0, ysum = 0, wsum = 0;
    bool isStable = true;
    for (int j = i; j > 0; --j) {
      int a = rs[j].y2 - rs[j].y1;
      xsum += (long long)a * a * a * (rs[j].x1 + rs[j].x2);
      ysum += (long long)a * a * a * (rs[j].y1 + rs[j].y2);
      wsum += (long long)a * a * a;
      double gx = 1.0 * xsum / 2 / wsum;
      double gy = 1.0 * ysum / 2 / wsum;
      if (!pointInRect(gx, gy, rs[j - 1])) {
        isStable = false;
        break;
      }
    }
    if (!isStable) break;
  }
  printf("%d\n", i);
  return 0;
}
