#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  float x1[n], x2[n], y1[n], y2[n];
  float w[n], cw[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    int weight = pow(fabs(x2[i] - x1[i]), 3);
    sum += weight;
    w[i] = weight;
    cw[i] = sum;
  }
  pair<float, float> dp[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dp[i][j] = {0, 0};
  for (int i = 0; i < n; i++)
    dp[i][i] = {(x1[i] + x2[i]) / 2, (y1[i] + y2[i]) / 2};
  for (int j = 1; j < n; j++)
    dp[0][j] = {
        (cw[j - 1] * dp[0][j - 1].first + w[j] * dp[j][j].first) / cw[j],
        (cw[j - 1] * dp[0][j - 1].second + w[j] * dp[j][j].second) / cw[j]};
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      dp[i][j].first = ((cw[j - 1] - cw[i - 1]) * dp[i][j - 1].first +
                        w[j] * dp[j][j].first) /
                       (cw[j] - cw[i - 1]);
      dp[i][j].second = ((cw[j - 1] - cw[i - 1]) * dp[i][j - 1].second +
                         w[j] * dp[j][j].second) /
                        (cw[j] - cw[i - 1]);
    }
  }
  for (int j = 1; j < n; j++) {
    for (int i = 1; i <= j; i++) {
      if ((dp[i][j].first < min(x1[i - 1], x2[i - 1]) ||
           (dp[i][j].first > max(x1[i - 1], x2[i - 1])) ||
           (dp[i][j].second < min(y1[i - 1], y2[i - 1])) ||
           (dp[i][j].second > max(y1[i - 1], y2[i - 1])))) {
        cout << j << '\n';
        return 0;
      }
    }
  }
  cout << n;
  return 0;
}
