#include <bits/stdc++.h>
using namespace std;
const int MaxN = 102, MaxC = 0x3F3F3F3F, NA = -1;
int main(void) {
  int x1[MaxN], y1[MaxN], x2[MaxN], y2[MaxN], xc[MaxN], yc[MaxN];
  int d[MaxN], e[MaxN];
  int i, m, n;
  long long w, x, y;
  while (scanf(" %d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf(" %d %d %d %d", &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]);
      x1[i] <<= 1;
      y1[i] <<= 1;
      x2[i] <<= 1;
      y2[i] <<= 1;
      xc[i] = (x1[i] + x2[i]) >> 1;
      yc[i] = (y1[i] + y2[i]) >> 1;
      d[i] = x2[i] - x1[i];
      e[i] = d[i] * d[i] * d[i];
    }
    for (m = 1; m < n; m++) {
      x = xc[m] * e[m];
      y = yc[m] * e[m];
      w = e[m];
      for (i = m - 1; i >= 0; i--) {
        if (x < x1[i] * w || y < y1[i] * w || x > x2[i] * w || y > y2[i] * w)
          break;
        x += xc[i] * e[i];
        y += yc[i] * e[i];
        w += e[i];
      }
      if (i >= 0) break;
    }
    printf("%d\n", m);
  }
  return 0;
}
