#include <bits/stdc++.h>
using namespace std;
long long dp[3010][3010];
long long ans[3010];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  vector<pair<long long, long long> > x, y;
  cin >> n;
  for (__typeof(n) i = 0; i < (n); i++) {
    int ax, bx, ay, by;
    cin >> ax >> ay >> bx >> by;
    x.push_back(make_pair(min(ax, bx), max(ax, bx)));
    y.push_back(make_pair(min(ay, by), max(ay, by)));
  }
  for (__typeof(n) i = 0; i < (n); i++)
    if (i) {
      double sum = 0, myx = 0, myy = 0;
      int j = i;
      while (j > 0) {
        double cube = 1.0 * (x[j].first - x[j].second) *
                      (x[j].first - x[j].second) * (x[j].first - x[j].second);
        myx = (((x[j].first + x[j].second) * cube) / 2) + (myx * sum);
        myy = (((y[j].first + y[j].second) * cube) / 2) + (myy * sum);
        sum += cube;
        myx /= sum, myy /= sum;
        if (myx + 1e-9 < double(x[j - 1].first) ||
            myx > double(x[j - 1].second) + 1e-9) {
          cout << i << endl;
          return 0;
        }
        if (myy + 1e-9 < double(y[j - 1].first) ||
            myy > double(y[j - 1].second) + 1e-9) {
          cout << i << endl;
          return 0;
        }
        j--;
      }
    }
  cout << n << endl;
  return 0;
}
