#include <bits/stdc++.h>
using namespace std;
const int zero = 1e-9;
double triple(double first) { return fabs(first * first * first); }
const int off = 0;
struct square {
  pair<int, int> w, e;
  void read() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    w.first = min(a, c) + off;
    w.second = min(b, d) + off;
    e.first = max(a, c) + off;
    e.second = max(b, d) + off;
  }
} a[1000];
int n;
struct point {
  double first, second, m;
  void make(const square &a) {
    first = (a.w.first + a.e.first) / 2.0;
    second = (a.w.second + a.e.second) / 2.0;
    m = triple(a.e.first - a.w.first);
  }
  bool inside(const square &a) {
    return (a.w.first - zero <= first && first <= a.e.first + zero &&
            a.w.second - zero <= second && second <= a.e.second + zero);
  }
} b[1000];
point merge(const point &a, const point &b) {
  point ret;
  ret.m = a.m + b.m;
  ret.first = (a.first * a.m + b.first * b.m) / ret.m;
  ret.second = (a.second * a.m + b.second * b.m) / ret.m;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    a[i].read();
    b[i].make(a[i]);
  }
  bool work(int);
  for (int i = 2; i <= n; ++i)
    if (!work(i)) {
      printf("%d\n", i - 1);
      return 0;
    }
  printf("%d\n", n);
  return 0;
}
bool work(int n) {
  point mass = b[n];
  for (int i = n - 1; i > 0; --i) {
    if (!mass.inside(a[i])) return false;
    mass = merge(b[i], mass);
  }
  return true;
}
