#include <bits/stdc++.h>
using namespace std;
const int limite = 1000000;
struct elem {
  int pos, entra, ind, antes;
  elem() {}
  elem(int pos, int entra, int ind, int antes)
      : pos(pos), entra(entra), ind(ind), antes(antes) {}
};
bool operator<(elem e1, elem e2) {
  if (e1.pos != e2.pos) return e1.pos < e2.pos;
  return e1.entra < e2.entra;
}
int d, n, m;
int erroneo[limite];
void calcula(vector<elem> &v, int cont) {
  int cuantos = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < int(v.size()); i++) {
    elem e = v[i];
    if (e.entra) {
      cuantos++;
    } else {
      if (cuantos - e.antes != cont) {
        erroneo[e.ind] = 1;
      }
    }
  }
}
int le[limite], top[limite], ri[limite], bot[limite];
int conttop, contbot, contle, contri;
void ordena(int &x, int &y) {
  if (x > y) swap(x, y);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> d >> n >> m;
  n = d;
  for (int i = 1; i <= n; i++) {
    cin >> le[i] >> top[i] >> ri[i] >> bot[i];
    ordena(le[i], ri[i]);
    ordena(top[i], bot[i]);
  }
  cin >> contle >> contri >> conttop >> contbot;
  {
    vector<elem> v;
    for (int i = 1; i <= n; i++) {
      v.push_back(elem(le[i], 1, i, 0));
      v.push_back(elem(ri[i], 0, i, le[i] < ri[i]));
    }
    calcula(v, contle);
  }
  {
    vector<elem> v;
    for (int i = 1; i <= n; i++) {
      v.push_back(elem(-ri[i], 1, i, 0));
      v.push_back(elem(-le[i], 0, i, le[i] < ri[i]));
    }
    calcula(v, contri);
  }
  {
    vector<elem> v;
    for (int i = 1; i <= n; i++) {
      v.push_back(elem(top[i], 1, i, 0));
      v.push_back(elem(bot[i], 0, i, top[i] < bot[i]));
    }
    calcula(v, conttop);
  }
  {
    vector<elem> v;
    for (int i = 1; i <= n; i++) {
      v.push_back(elem(-bot[i], 1, i, 0));
      v.push_back(elem(-top[i], 0, i, top[i] < bot[i]));
    }
    calcula(v, contbot);
  }
  for (int i = 1; i <= n; i++) {
    if (not erroneo[i]) {
      cout << i << endl;
      exit(0);
    }
  }
  cout << -1 << endl;
}
