#include <bits/stdc++.h>   using namespace std;   const double PI = acos(0) * 2;   const double EPS = 1e-8;   const long long MOD = 1e9 + 7;   const int MAXN = 1e5 + 5;   const int oo = 1e9;   const double foo = 1e30;   template <class T>   int getbit(T s, int i) {     return (s >> i) & 1;   }   template <class T>   T onbit(T s, int i) {     return s | (T(1) << i);   }   template <class T>   T offbit(T s, int i) {     return s & (~(T(1) << i));   }   template <class T>   int cntbit(T s) {     return __builtin_popcounll(s);   }   template <class T>   T sqr(T x) {     return x * x;   }   inline void addmod(int& a, int val, int p = MOD) {     if ((a = (a + val)) >= p) a -= p;   }   inline void submod(int& a, int val, int p = MOD) {     if ((a = (a - val)) < 0) a += p;   }   inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }   int d, n, m, vs[MAXN], cnt[4], has[MAXN][4];   vector<pair<int, int> > dX, dY;   int main() {     cin >> d;     cin >> n >> m;     for (int i = 0; i < d; i++) {       int x, y;       cin >> x >> y;       dX.push_back(make_pair(x, i));       dY.push_back(make_pair(y, i));       cin >> x >> y;       dX.push_back(make_pair(x, i));       dY.push_back(make_pair(y, i));     }     for (int i = 0; i < 4; i++) cin >> cnt[i];     sort(dX.begin(), dX.end());     sort(dY.begin(), dY.end());     int pass = 0;     memset(vs, 0, sizeof(vs));     int tot = 0;     for (int i = 0; i < ((int)(dX).size()); i++) {       if (i && dX[i].first != dX[i - 1].first) {         tot += pass;         pass = 0;       }       if (!vs[dX[i].second]) {         pass++;         vs[dX[i].second] = 1;         has[dX[i].second][0] = max(has[dX[i].second][0], tot);       } else {         has[dX[i].second][0] = max(has[dX[i].second][0], tot - 1);       }     }     pass = 0;     memset(vs, 0, sizeof(vs));     tot = 0;     for (int i = ((int)(dX).size()) - 1; i >= 0; i--) {       if (i != ((int)(dX).size()) - 1 && dX[i].first != dX[i + 1].first) {         tot += pass;         pass = 0;       }       if (!vs[dX[i].second]) {         pass++;         vs[dX[i].second] = 1;         has[dX[i].second][1] = max(has[dX[i].second][1], tot);       } else {         has[dX[i].second][1] = max(has[dX[i].second][1], tot - 1);       }     }     pass = 0;     memset(vs, 0, sizeof(vs));     tot = 0;     for (int i = 0; i < ((int)(dY).size()); i++) {       if (i && dY[i].first != dY[i - 1].first) {         tot += pass;         pass = 0;       }       if (!vs[dY[i].second]) {         pass++;         vs[dY[i].second] = 1;         has[dY[i].second][2] = max(has[dY[i].second][2], tot);       } else {         has[dY[i].second][2] = max(has[dY[i].second][2], tot - 1);       }     }     pass = 0;     memset(vs, 0, sizeof(vs));     tot = 0;     for (int i = ((int)(dY).size()) - 1; i >= 0; i--) {       if (i != ((int)(dY).size()) - 1 && dY[i].first != dY[i + 1].first) {         tot += pass;         pass = 0;       }       if (!vs[dY[i].second]) {         pass++;         vs[dY[i].second] = 1;         has[dY[i].second][3] = max(has[dY[i].second][3], tot);       } else {         has[dY[i].second][3] = max(has[dY[i].second][3], tot - 1);       }     }     for (int i = 0; i < d; i++) {       int check = 1;       for (int j = 0; j < 4; j++)         if (has[i][j] != cnt[j]) {           check = 0;           break;         }       if (check) {         cout << i + 1;         return 0;       }     }     cout << -1;     return 0;   }