#include <iostream>
using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int A[10010][4]={0};
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>A[i][0]>>A[i][1]>>A[i][2]>>A[i][3];
    }
    int x,y;
    int anw=0;
    cin>>x>>y;
    for(int i=1;i<=n;i++){
        if(A[i][0]<=x&&x<=A[i][0]+A[i][2]&&A[i][1]<=y&&y<=A[i][1]+A[i][3]) anw=i;
    }
    cout<<anw;
}