#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = 1 << 30;
const long long LINF = 1ll << 60;
const int BUFFER_SZ = 1 << 15;
const int MOD = 1000 * 1000 * 1000 + 7;
char BUFFER[BUFFER_SZ];
int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
double gd() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long gll() {
  long long x;
  cin >> x;
  return x;
}
vector<int> gvi(int n) {
  vector<int> a;
  while (n-- > 0) a.push_back(gi());
  return a;
}
string gs() {
  scanf("%s", BUFFER);
  return string(BUFFER);
}
template <class T>
void print(vector<T> &x, string format) {
  format += "%c";
  for (int i = 0; i < x.size(); ++i)
    printf(format.c_str(), x[i], i + 1 == x.size() ? '\n' : ' ');
}
int main() {
  int n = gi();
  int X1[1111];
  int Y1[1111];
  int X2[1111];
  int Y2[1111];
  int res = n;
  int ex = 0;
  for (int i = 0; i < n; ++i) {
    X1[i] = gi();
    Y1[i] = gi();
    X2[i] = gi();
    Y2[i] = gi();
    if (X1[i] > X2[i]) swap(X1[i], X2[i]);
    if (Y1[i] > Y2[i]) swap(Y1[i], Y2[i]);
    double w = (X2[i] - X1[i]) * (Y2[i] - Y1[i]) * (Y2[i] - Y1[i]);
    double x = (X1[i] + X2[i]) / 2.0;
    double y = (Y1[i] + Y2[i]) / 2.0;
    for (int j = i - 1; j >= 0; --j) {
      if (X1[j] - 1e-8 <= x && x <= X2[j] + 1e-8 && Y1[j] - 1e-8 <= y &&
          y <= Y2[j] + 1e-8) {
        double ww = (X2[j] - X1[j]) * (Y2[j] - Y1[j]) * (Y2[j] - Y1[j]);
        double xx = (X1[j] + X2[j]) / 2.0;
        double yy = (Y1[j] + Y2[j]) / 2.0;
        x = (x * w + xx * ww) / (w + ww);
        y = (y * w + yy * ww) / (w + ww);
        w += ww;
      } else {
        res = i;
        ex = 1;
        break;
      }
    }
    if (ex) break;
  }
  printf("%d\n", res);
  return 0;
}
