#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x1(n), y1(n), x2(n), y2(n);
  for (int i = 0; i < n; ++i) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (y1[i] > y2[i]) swap(y1[i], y2[i]);
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= i; ++j) {
      double first = 0, second = 0, m = 0;
      for (int k = j; k <= i; ++k) {
        double m1 = (x2[k] - x1[k]) * (x2[k] - x1[k]) * (x2[k] - x1[k]);
        first += (x1[k] + x2[k]) * m1;
        second += (y1[k] + y2[k]) * m1;
        m += m1;
      }
      first /= (2 * m);
      second /= (2 * m);
      if (first > x2[j - 1]) {
        cout << i << endl;
        return 0;
      }
      if (first < x1[j - 1]) {
        cout << i << endl;
        return 0;
      }
      if (second > y2[j - 1]) {
        cout << i << endl;
        return 0;
      }
      if (second < y1[j - 1]) {
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << n << endl;
  return 0;
}
