#include <bits/stdc++.h>   using namespace std;   int i, j, k, l;   int n, m, d, a[100010][4];   int ms[11111];   double cx, cy, ccx, ccy;   int x1, stupid_cmath, x2, y2;   int main() {     cin >> n;     for (i = 0; i < n; ++i) {       cin >> x1 >> stupid_cmath >> x2 >> y2;       a[i][0] = ((x1) < (x2) ? (x1) : (x2));       a[i][1] = ((stupid_cmath) < (y2) ? (stupid_cmath) : (y2));       a[i][2] = ((x1) > (x2) ? (x1) : (x2));       a[i][3] = ((stupid_cmath) > (y2) ? (stupid_cmath) : (y2));       ms[i] = (a[i][2] - a[i][0]) * (a[i][2] - a[i][0]) * (a[i][2] - a[i][0]);     }     for (i = 0; i < n; ++i) {       for (j = i - 1; j >= 0; --j) {         cx = cy = 0;         m = 0;         for (k = j + 1; k <= i; ++k) {           cx += (a[k][0] + a[k][2]) / 2. * ms[k];           cy += (a[k][1] + a[k][3]) / 2. * ms[k];           m += ms[k];         }         cx /= m;         cy /= m;         if (cx < a[j][0] || cx > a[j][2] || cy < a[j][1] || cy > a[j][3]) {           cout << i << endl;           return 0;         }       }     }     cout << n;     return 0;   }   