#include <bits/stdc++.h>
using namespace std ;
int n ;
int a [ 100005 ], b [ 100005 ], c [ 100005 ], d [ 100005 ] ;
int x, y ;
int ans = -1 ;
int main () {
cin >> n ;
for ( int i = 1 ; i <= n ; i ++ )
cin >> a [ i ] >> b [ i ] >> c [ i ] >> d [ i ] ;
cin >> x >> y ;
for ( int i = 1 ; i <= n ; i ++ )
if ( x >= a [ i ] and x <= c [ i ] and y >= b [ i ] and y <= d [ i ] )
ans = i ;
if ( ans != 0 ) cout << ans ;
else cout << -1 ;
}