#include <iostream>
#include<stack>
using namespace std;

struct Carpet{
    int id;
    int x1,y1;
    int x2,y2;
};
int main() {
    int n;
    cin>>n;
    stack<Carpet>st;
    for(int i=1;i<=n;i++){
        Carpet c;
        c.id=i;
        cin>>c.x1>>c.y1>>c.x2>>c.y2;
        st.push(c);
    }
    int x,y;
    cin>>x>>y;
    while(!st.empty()){
        Carpet top=st.top();
        st.pop();
        bool xin=(x>=top.x1)&&(x<=top.x1+top.x2);
        bool yin=(y>=top.y1)&&(y<=top.y1+top.y2);
        if(xin&&yin){
            cout<<top.id<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}
// 64 位输出请用 printf("%lld")