#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool updmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool updmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int mod = (int)(10e9 + 7);
struct Endpoint {
  int id;
  int n;
  bool isStart;
  bool isSame;
  bool operator<(const Endpoint &that) const {
    return n == that.n ? isStart : n < that.n;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int d, n, m;
  cin >> d >> n >> m;
  vector<Endpoint> X, Y;
  for (__typeof(d) i = (0) - ((0) > (d)); i != (d) - ((0) > (d));
       i += 1 - 2 * ((0) > (d))) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    X.emplace_back(Endpoint{i, x1, x1 <= x2, x1 == x2});
    X.emplace_back(Endpoint{i, x2, x2 < x1, x1 == x2});
    Y.emplace_back(Endpoint{i, y1, y1 <= y2, y1 == y2});
    Y.emplace_back(Endpoint{i, y2, y2 < y1, y1 == y2});
  }
  int l, r, u, dow;
  cin >> l >> r >> u >> dow;
  vector<int> cntl(d), cntr(d), cntu(d), cntd(d);
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  int left = 0, prev = -1, templeft = 0;
  for (auto x : X) {
    if (prev != x.n) {
      left += templeft;
      templeft = 0;
      prev = x.n;
    }
    if (x.isStart) {
      templeft++;
    } else {
      cntl[x.id] = x.isSame ? left : left - 1;
    }
  }
  int right = 0, tempright = 0;
  prev = -1;
  for (auto it = X.rbegin(); it != X.rend(); it++) {
    if (prev != it->n) {
      right += tempright;
      tempright = 0;
      prev = it->n;
    }
    if (!it->isStart) {
      tempright++;
    } else {
      cntr[it->id] = it->isSame ? right : right - 1;
    }
  }
  int up = 0, tempup = 0;
  prev = -1;
  for (auto y : Y) {
    if (prev != y.n) {
      up += tempup;
      tempup = 0;
      prev = y.n;
    }
    if (y.isStart) {
      tempup++;
    } else {
      cntu[y.id] = y.isSame ? up : up - 1;
    }
  }
  int down = 0, tempdown = 0;
  prev = -1;
  for (auto it = Y.rbegin(); it != Y.rend(); it++) {
    if (prev != it->n) {
      down += tempdown;
      tempdown = 0;
      prev = it->n;
    }
    if (!it->isStart) {
      tempdown++;
    } else {
      cntd[it->id] = it->isSame ? down : down - 1;
    }
  }
  bool pos = false;
  for (__typeof(d) i = (0) - ((0) > (d)); i != (d) - ((0) > (d));
       i += 1 - 2 * ((0) > (d))) {
    if (cntl[i] == l && cntr[i] == r && cntu[i] == u && cntd[i] == dow) {
      cout << i + 1 << endl;
      pos = true;
      break;
    }
  }
  if (!pos) cout << -1 << endl;
  return 0;
}
