#include <bits/stdc++.h>
using namespace std;
struct node {
  int x1, y1, x2, y2;
  int v;
  double x, y;
};
node ans[105];
void QV(int i) {
  ans[i].v = abs(ans[i].x1 - ans[i].x2) * abs(ans[i].y1 - ans[i].y2) *
             abs(ans[i].y1 - ans[i].y2);
  ans[i].x = (ans[i].x1 + ans[i].x2) / 2.0;
  ans[i].y = (ans[i].y1 + ans[i].y2) / 2.0;
}
struct nn {
  double x, y;
  int v;
};
nn sum[105];
bool judge1(int n) {
  int i = n - 1;
  {
    if (sum[n].x < ans[i].x1 || sum[n].x > ans[i].x2) return true;
    if (sum[n].y < ans[i].y1 || sum[n].y > ans[i].y2) return true;
  }
  return false;
}
bool judge(int n) {
  int i;
  sum[n].v = ans[n].v;
  sum[n].x = ans[n].x;
  sum[n].y = ans[n].y;
  for (i = n; i > 0; i--) {
    if (judge1(i)) return true;
    sum[i - 1].v = sum[i].v + ans[i - 1].v;
    sum[i - 1].x =
        (sum[i].x * sum[i].v + ans[i - 1].v * ans[i - 1].x) / sum[i - 1].v;
    sum[i - 1].y =
        (sum[i].y * sum[i].v + ans[i - 1].v * ans[i - 1].y) / sum[i - 1].v;
  }
  return false;
}
int main() {
  int i, n;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%d%d%d%d", &ans[i].x1, &ans[i].y1, &ans[i].x2, &ans[i].y2);
      if (ans[i].x1 > ans[i].x2) swap(ans[i].x1, ans[i].x2);
      if (ans[i].y1 > ans[i].y2) swap(ans[i].y1, ans[i].y2);
      QV(i);
    }
    for (i = 1; i < n; i++) {
      if (judge(i)) break;
    }
    printf("%d\n", i);
  }
  return 0;
}
