#include <bits/stdc++.h>
using namespace std;
struct cube {
  double x1, y1, x2, y2, x, y, m;
};
bool lessx(double x, double y) {
  if ((y - x) >= 0)
    return true;
  else
    return false;
}
bool f(double x, double x1, double x2) {
  if ((lessx(x1, x) && lessx(x, x2)) || (lessx(x2, x) && lessx(x, x1)))
    return true;
  else
    return false;
}
int main() {
  int n;
  cin >> n;
  vector<cube> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
    a[i].x = (a[i].x1 + a[i].x2) / 2;
    a[i].y = (a[i].y1 + a[i].y2) / 2;
    a[i].m =
        fabs((a[i].x2 - a[i].x1) * (a[i].x2 - a[i].x1) * (a[i].x2 - a[i].x1));
  }
  for (int j = 1; j < n; j++) {
    for (int i = 0; i < j; i++) {
      double xc = 0, yc = 0, mc = 0;
      for (int k = i + 1; k <= j; k++) {
        xc += a[k].m * a[k].x;
        yc += a[k].m * a[k].y;
        mc += a[k].m;
      }
      if (!f(xc / mc, a[i].x1, a[i].x2) || !f(yc / mc, a[i].y1, a[i].y2)) {
        cout << j;
        return 0;
      }
    }
  }
  cout << n;
  return 0;
}
