#include <bits/stdc++.h> using namespace std; int main() { int a[10010]; int b[10010]; int c[10010]; int d[10010];

int n , x , y;
cin >> n;

for( int i = 1 ; i <= n ; i ++ )
{
    cin >> a[i] >> b[i] >> c[i] >> d[i];
}
cin >> x >> y;

int ans = -1;
for( int i = n ; i >= 1 ; i -- )
{
    if(( x >= a[i] && x <= a[i] + c[i] ) && (y >= b[i] && y <= b[i] + d[i]))
    {
        ans = i;
        break;
    }
}
cout << ans;
return 0;

}