The input consists one test case.The first line contains an integer n(n<=300),which means the number of students.The second line contains n integers means the exam results of these n students.As you know,full mark is 500.The third line contains an integer m,which means the number of professors.Then follows m lines,each line contains two integer,A and B(0<=A,B<=500),which means professor's recruitment criteria.
For each test case, you should output m lines with the recruited student's exam result.If no student meet professor's requirement,you should output -1.
7 306 304 389 342 343 355 302 4 350 390 380 400 307 303 500 400
389 -1 306 -1