/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner (System.in);
int master_count,skill_count;
while(in.hasNextInt()){
int maxDefense = 0;
int maxDamage = 0;
int maxLife = 0;
//怪兽数量以及技能数量输入
master_count = in.nextInt();
skill_count = in.nextInt();
//怪兽属性信息输入
for(int index = 0 ; index < master_count ; index ++){
master_life[index] = in.nextInt();
master_defense[index] = in.nextInt();
maxDefense = findMax(maxDefense,master_defense[index]);
maxLife = findMax(maxLife,master_life[index]);
}
//技能属性信息输入
for(int index = 0 ; index < skill_count ; index ++){
skill_consume[index] = in.nextInt();
skill_damage[index] = in.nextInt();
maxDamage = findMax(maxDamage,skill_damage[index]);
}
if(maxDamage <= maxDefense ){
System.out.println(\"-1\");
}else{
System.out.println(\"-1\");
}
}