#include <bits/stdc++.h>
using namespace std;
int x1[110];
int botva[110];
int x2[110];
int y2[110];
long double xc[110];
long double yc[110];
int m[110];
const long double eps = 1e-05;
bool inside(long double x1, long double botva, long double x2, long double y2,
            long double a, long double b) {
  if (a < x1 - eps || a > x2 + eps) return false;
  if (b < botva - eps || b > y2 + eps) return false;
  cerr << "!!!!!!" << endl;
  return true;
}
bool check(int k) {
  long double x = 0, y = 0;
  int m = 0;
  for (int i = k; i >= 0; i--) {
    x = (x * m + xc[i] * ::m[i]) / (m + ::m[i]);
    y = (y * m + yc[i] * ::m[i]) / (m + ::m[i]);
    m += ::m[i];
    if (i == 0) {
      if (!inside(x1[i], botva[i], x2[i], y2[i], x, y)) return false;
    } else {
      if (!inside(max(x1[i], x1[i - 1]), max(botva[i], botva[i - 1]),
                  min(x2[i], x2[i - 1]), min(y2[i], y2[i - 1]), x, y))
        return false;
    }
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d", &x1[i], &botva[i], &x2[i], &y2[i]);
    int a = abs(x2[i] - x1[i]);
    m[i] = a * a * a;
    xc[i] = (x1[i] + x2[i]) / 2.0;
    yc[i] = (botva[i] + y2[i]) / 2.0;
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (botva[i] > y2[i]) swap(botva[i], y2[i]);
    if (!check(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("%d\n", n);
  return 0;
}
