#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, pair<int, int> > > sofas;
int cnt_lt[100001];
int cnt_rt[100001];
int cnt_tt[100001];
int cnt_bt[100001];
int main() {
  int d;
  cin >> d;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < d; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    sofas.push_back(make_pair(make_pair(x1, y1), make_pair(x2, y2)));
    cnt_lt[min(x1, x2)]++;
    cnt_rt[max(x1, x2)]++;
    cnt_tt[min(y1, y2)]++;
    cnt_bt[max(y1, y2)]++;
  }
  for (int i = 1; i < n; i++) {
    cnt_lt[i] += cnt_lt[i - 1];
  }
  for (int i = 1; i < m; i++) {
    cnt_tt[i] += cnt_tt[i - 1];
  }
  for (int i = n - 1; i >= 0; i--) {
    cnt_rt[i] += cnt_rt[i + 1];
  }
  for (int i = m - 1; i >= 0; i--) {
    cnt_bt[i] += cnt_bt[i + 1];
  }
  int cnt_l, cnt_r, cnt_t, cnt_b;
  cin >> cnt_l >> cnt_r >> cnt_t >> cnt_b;
  bool found = false;
  for (int i = 0; i < d; i++) {
    int x1, y1, x2, y2;
    x1 = sofas[i].first.first;
    x2 = sofas[i].second.first;
    y1 = sofas[i].first.second;
    y2 = sofas[i].second.second;
    int my_cnt_l = cnt_lt[max(x1, x2) - 1];
    if (x1 != x2) my_cnt_l--;
    if (my_cnt_l != cnt_l) continue;
    int my_cnt_r = cnt_rt[min(x1, x2) + 1];
    if (x1 != x2) my_cnt_r--;
    if (my_cnt_r != cnt_r) continue;
    int my_cnt_t = cnt_tt[max(y1, y2) - 1];
    if (y1 != y2) my_cnt_t--;
    if (my_cnt_t != cnt_t) continue;
    int my_cnt_b = cnt_bt[min(y1, y2) + 1];
    if (y1 != y2) my_cnt_b--;
    if (my_cnt_b != cnt_b) continue;
    found = true;
    cout << i + 1 << endl;
  }
  if (!found) cout << -1 << endl;
  return 0;
}
