#include <bits/stdc++.h>
using namespace std;
struct brick {
  int x1, y1, x2, y2;
  inline bool outside(double x, double y) {
    double mnx = min(x1, x2) - 1e-9;
    double mxx = max(x1, x2) + 1e-9;
    if (x >= mnx && x <= mxx) {
      double mny = min(y1, y2) - 1e-9;
      double mxy = max(y1, y2) + 1e-9;
      if (y >= mny && y <= mxy) return false;
    }
    return true;
  }
};
brick s[111];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i].x1 >> s[i].y1 >> s[i].x2 >> s[i].y2;
    double x = (double)(s[i].x1 + s[i].x2) * 0.5;
    double y = (double)(s[i].y1 + s[i].y2) * 0.5;
    int mass = abs(s[i].x1 - s[i].x2);
    mass = mass * mass * mass;
    for (int u = i - 1; u >= 0; u--) {
      if (s[u].outside(x, y)) {
        cout << i << endl;
        return 0;
      }
      double curx = (double)(s[u].x1 + s[u].x2) * 0.5;
      double cury = (double)(s[u].y1 + s[u].y2) * 0.5;
      int add = abs(s[u].x1 - s[u].x2);
      add = add * add * add;
      x = (x * mass + curx * add) / (mass + add);
      y = (y * mass + cury * add) / (mass + add);
      mass += add;
    }
  }
  cout << n << endl;
  return 0;
}
