#include <bits/stdc++.h>
using namespace std;
int N, X1[111], X2[111], Y1[111], Y2[111], Tm[111];
double Tx[111], Ty[111];
bool fit(double x, double y, int x1, int y1, int x2, int y2) {
  if (x + 1e-8 < x1 || y + 1e-8 < y1 || x - 1e-8 > x2 || y - 1e-8 > y2)
    return false;
  return true;
}
bool add(int a) {
  int i;
  double ntx, nty;
  Tx[a] = ((double)X2[a] + X1[a]) / 2;
  Ty[a] = ((double)Y2[a] + Y1[a]) / 2;
  Tm[a] = ((X2[a] - X1[a]) * (X2[a] - X1[a]) * (X2[a] - X1[a]));
  for (i = 0; i < a; i++) {
    ntx = (double)(Tm[i] * Tx[i] + Tm[a] * Tx[a]) / (Tm[i] + Tm[a]);
    nty = (double)(Tm[i] * Ty[i] + Tm[a] * Ty[a]) / (Tm[i] + Tm[a]);
    Tx[i] = ntx;
    Ty[i] = nty;
    Tm[i] = Tm[i] + ((X2[a] - X1[a]) * (X2[a] - X1[a]) * (X2[a] - X1[a]));
  }
  for (i = 0; i < a; i++) {
    if (!fit(Tx[i + 1], Ty[i + 1], X1[i], Y1[i], X2[i], Y2[i])) return false;
  }
  return true;
}
int main(int argc, char *argv[]) {
  int i, a1, a2;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d%d%d%d", X1 + i, Y1 + i, X2 + i, Y2 + i);
    a2 = max(X1[i], X2[i]);
    a1 = min(X1[i], X2[i]);
    X2[i] = a2;
    X1[i] = a1;
    a2 = max(Y1[i], Y2[i]);
    a1 = min(Y1[i], Y2[i]);
    Y2[i] = a2;
    Y1[i] = a1;
  }
  for (i = 0; i < N; i++) {
    if (!add(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("%d\n", N);
  return 0;
}
