#include <bits/stdc++.h>
using namespace std;
void readline(char *s) {
  int len = 0;
  char c;
  for (c = ((char)fgetc(stdin)); c != '\n';
       s[len++] = c, c = ((char)fgetc(stdin)))
    ;
  s[len] = 0;
}
void readstr(char *s) {
  int len = 0;
  char c;
  for (c = ((char)fgetc(stdin)); c != ' ' && c != '\n';
       s[len++] = c, c = ((char)fgetc(stdin)))
    ;
  s[len] = 0;
}
void printstr(const char *s) {
  int len = strlen(s);
  for (int(i) = (0); (i) <= (len - 1); i++) fputc((s[i]), stdout);
}
void to_lower(char *s, int L, int R) {
  for (int(i) = (L); (i) <= (R); i++)
    if (((s[i]) >= 'A' && (s[i]) <= 'Z')) s[i] = s[i] - 'A' + 'a';
}
void to_upper(char *s, int L, int R) {
  for (int(i) = (L); (i) <= (R); i++)
    if (((s[i]) >= 'a' && (s[i]) <= 'z')) s[i] = s[i] - 'a' + 'A';
}
long long readll() {
  char c;
  long long ans = 0, x = 1;
  for (c = ((char)fgetc(stdin)); !((c) >= '0' && (c) <= '9') && c != '-';
       c = ((char)fgetc(stdin)))
    ;
  if (c == '-') x = -1, c = ((char)fgetc(stdin));
  for (; ((c) >= '0' && (c) <= '9');
       ans = ans * 10 + c - '0', c = ((char)fgetc(stdin)))
    ;
  return ans * x;
}
void printll(long long x) {
  int a[25], cnt = 0;
  if (x == 0) {
    fputc(('0'), stdout);
    return;
  }
  if (x < 0) fputc(('-'), stdout), x = -x;
  for (; x; a[cnt++] = x - x / 10 * 10, x /= 10)
    ;
  for (int(i) = (cnt - 1); (i) >= (0); i--) fputc((a[i] + '0'), stdout);
}
vector<int> v;
int d, n, m, x[2][100005], y[2][100005], cnt[4][100005];
int main() {
  d = ((int)readll());
  n = ((int)readll()), m = ((int)readll());
  for (int(i) = (1); (i) <= (d); i++) {
    x[0][i] = ((int)readll()), y[0][i] = ((int)readll()),
    x[1][i] = ((int)readll()), y[1][i] = ((int)readll());
  }
  cnt[0][0] = ((int)readll()), cnt[1][0] = ((int)readll()),
  cnt[2][0] = ((int)readll()), cnt[3][0] = ((int)readll());
  v.clear();
  for (int(i) = (1); (i) <= (d); i++) {
    v.push_back(min(x[0][i], x[1][i]));
  }
  sort(v.begin(), v.end());
  for (int(i) = (1); (i) <= (d); i++) {
    vector<int>::iterator it =
        lower_bound(v.begin(), v.end(), max(x[0][i], x[1][i]));
    cnt[0][i] = it - v.begin();
    if (max(x[0][i], x[1][i]) != min(x[0][i], x[1][i])) cnt[0][i]--;
  }
  v.clear();
  for (int(i) = (1); (i) <= (d); i++) {
    v.push_back(max(x[0][i], x[1][i]));
  }
  sort(v.begin(), v.end());
  for (int(i) = (1); (i) <= (d); i++) {
    vector<int>::iterator it =
        upper_bound(v.begin(), v.end(), min(x[0][i], x[1][i]));
    cnt[1][i] = v.end() - it;
    if (max(x[0][i], x[1][i]) != min(x[0][i], x[1][i])) cnt[1][i]--;
  }
  v.clear();
  for (int(i) = (1); (i) <= (d); i++) {
    v.push_back(min(y[0][i], y[1][i]));
  }
  sort(v.begin(), v.end());
  for (int(i) = (1); (i) <= (d); i++) {
    vector<int>::iterator it =
        lower_bound(v.begin(), v.end(), max(y[0][i], y[1][i]));
    cnt[2][i] = it - v.begin();
    if (max(y[0][i], y[1][i]) != min(y[0][i], y[1][i])) cnt[2][i]--;
  }
  v.clear();
  for (int(i) = (1); (i) <= (d); i++) {
    v.push_back(max(y[0][i], y[1][i]));
  }
  sort(v.begin(), v.end());
  for (int(i) = (1); (i) <= (d); i++) {
    vector<int>::iterator it =
        upper_bound(v.begin(), v.end(), min(y[0][i], y[1][i]));
    cnt[3][i] = v.end() - it;
    if (max(y[0][i], y[1][i]) != min(y[0][i], y[1][i])) cnt[3][i]--;
  }
  int ans = -1;
  for (int(i) = (1); (i) <= (d); i++) {
    if (cnt[0][i] == cnt[0][0] && cnt[1][i] == cnt[1][0] &&
        cnt[2][i] == cnt[2][0] && cnt[3][i] == cnt[3][0]) {
      ans = i;
      break;
    }
  }
  printll((long long)(ans));
  return 0;
}
