Good Teacher

I want to be a good teacher, so at least I need to remember all the student names. However, there are too many students, so I failed. It is a shame, so I don’t want my students to know this. Whenever I need to call someone, I call his CLOSEST student instead. For example, there are 10 students: A??D???H?? Then, to call each student, I use this table: Pos Reference 1A 2 right of A 3 left of D 4D 5 right of D 6 middle of D and H 7 left of H 8H 9 right of H 10 right of right of H Input There is only one test case. The first line contains n, the number of students (1 ≤ n ≤ 100). The next line contains n space-separated names. Each name is either ‘?’ or a string of no more than 3 English letters. There will be at least one name not equal to ‘?’. The next line contains q, the number of queries (1 ≤ q ≤ 100). Then each of the next q lines contains the position p (1 ≤ p ≤ n) of a student (counting from left). Output Print q lines, each for a student. Note that ‘middle of X and Y ’ is only used when X and Y are both closest of the student, and X is always to his left. Sample Input 10 A??D???H?? 4 3 8 6 10

2/2 Sample Output left of D H middle of D and H right of right of H