#include <bits/stdc++.h>
using namespace std;
struct sofa {
  int lm, rm, tm, bm;
  int id;
  sofa(int x1, int y1, int x2, int y2, int id) {
    lm = min(x1, x2);
    rm = max(x1, x2);
    tm = min(y1, y2);
    bm = max(y1, y2);
    (this->id) = id;
  }
};
bool cmp1(sofa a, sofa b) { return a.lm < b.lm; }
bool cmp2(sofa a, sofa b) { return a.rm > b.rm; }
bool cmp3(sofa a, sofa b) { return a.tm < b.tm; }
bool cmp4(sofa a, sofa b) { return a.bm > b.bm; }
int main() {
  int d;
  int n, m;
  int cntl, cntr, cntt, cntb;
  vector<sofa> v;
  cin >> d >> n >> m;
  for (int x1, y1, x2, y2, i = 1; i <= d; ++i) {
    cin >> x1 >> y1 >> x2 >> y2;
    v.push_back(sofa(x1, y1, x2, y2, i));
  }
  cin >> cntl >> cntr >> cntt >> cntb;
  sort(v.begin(), v.end(), cmp1);
  vector<sofa> v1;
  for (int i = 0; i < v.size(); ++i) {
    int x = v[i].rm;
    int L = 0, R = (int)v.size() - 1;
    if (v[0].lm >= x) {
      if (cntl == 0) v1.push_back(v[i]);
      continue;
    }
    while (L < R) {
      int m = (L + R + 1) >> 1;
      if (v[m].lm < x)
        L = m;
      else
        R = m - 1;
    }
    int num = L + 1;
    if (v[i].lm < v[i].rm) num--;
    if (num == cntl) v1.push_back(v[i]);
  }
  sort(v.begin(), v.end(), cmp2);
  vector<sofa> v2;
  for (int i = 0; i < v1.size(); ++i) {
    int x = v1[i].lm;
    int L = 0, R = (int)v.size() - 1;
    if (v[0].rm <= x) {
      if (cntr == 0) v2.push_back(v1[i]);
      continue;
    }
    while (L < R) {
      int m = (L + R + 1) >> 1;
      if (v[m].rm > x)
        L = m;
      else
        R = m - 1;
    }
    int num = L + 1;
    if (v1[i].lm < v1[i].rm) num--;
    if (num == cntr) v2.push_back(v1[i]);
  }
  sort(v.begin(), v.end(), cmp3);
  vector<sofa> v3;
  for (int i = 0; i < v2.size(); ++i) {
    int x = v2[i].bm;
    int L = 0, R = (int)v.size() - 1;
    if (v[0].tm >= x) {
      if (cntt == 0) v3.push_back(v2[i]);
      continue;
    }
    while (L < R) {
      int m = (L + R + 1) >> 1;
      if (v[m].tm < x)
        L = m;
      else
        R = m - 1;
    }
    int num = L + 1;
    if (v2[i].tm < v2[i].bm) num--;
    if (num == cntt) v3.push_back(v2[i]);
  }
  sort(v.begin(), v.end(), cmp4);
  vector<sofa> v4;
  for (int i = 0; i < v3.size(); ++i) {
    int x = v3[i].tm;
    int L = 0, R = (int)v.size() - 1;
    if (v[0].bm <= x) {
      if (cntb == 0) v4.push_back(v3[i]);
      continue;
    }
    while (L < R) {
      int m = (L + R + 1) >> 1;
      if (x < v[m].bm)
        L = m;
      else
        R = m - 1;
    }
    int num = L + 1;
    if (v3[i].tm < v3[i].bm) num--;
    if (num == cntb) v4.push_back(v3[i]);
  }
  if (v4.size() == 0) {
    puts("-1");
  } else
    cout << v4[0].id << endl;
}
