import java.util.Scanner;

public class Main {
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Bean []bean = new Bean[n];
        for(int i = 0;i<n;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int x_long = sc.nextInt();
            int y_long = sc.nextInt();
            bean[i] = new Bean(x, y, x_long, y_long);
        }
        int x = sc.nextInt();
        int y = sc.nextInt();
        boolean flag = false;
        for(int i = n-1;i>-1;i--){
            if(bean[i].find(x,y)){
                System.out.println(i+1);
                flag = true;
                break;
            }
        }
        if(!flag){
             System.out.println(-1);
        }
    }


}
    class Bean{
        private int x;
        private int y;
        private int x_long;
        private int y_long;
        public Bean(){

        }
        public Bean(int x,int y,int x_long,int y_long){
            this.x = x;
            this.y = y;
            this.x_long = x_long;
            this.y_long = y_long;
        }
        public boolean find(int find_x,int find_y){
            if(find_x>=x&&find_x<=x+x_long&&find_y>=y&&find_y<=y+y_long){
                return true;
            }
            return false;
        }
    }