https://www.luogu.org/problemnew/show/P1003
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
private static Scanner cin;
public static void main(String args[]) throws Exception {
cin = new Scanner(System.in);
int n = cin.nextInt();
LinkedList<Carpet> carpets = new LinkedList<Carpet>();
int a,b,g,k;
for(int i=1; i<=n; i++) {
a = cin.nextInt();
b = cin.nextInt();
g = cin.nextInt();
k = cin.nextInt();
carpets.addFirst(new Carpet(i,a,b,g,k));
}
int x = cin.nextInt();
int y = cin.nextInt();
Iterator<Carpet> it = carpets.iterator();
int ret = -1;
while(it.hasNext()) {
Carpet carpet = (Carpet)it.next();
if(carpet.covered(x, y)) {
ret = carpet.getId();
break;
}
}
System.out.println(ret);
}
}
final class Carpet{
int id,x1,y1,x2,y2;
public Carpet(int id, int x,int y, int length, int height) {
this.id = id;
x1 = x;
y1 = y;
x2 = x+length;
y2 = y+height;
}
public boolean covered(int x, int y) {
boolean ret =false;
if(x>=x1 && y>=y1 && x<=x2 && y<=y2) {
ret = true;
}
return ret;
}
public int getId() {
return id;
}
}