QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#3789. Good Teacher

Estadísticas

I want to be a good teacher, so I decided to memorize all my students' names. However, I gave up shortly after because there were too many students to remember. But I cannot let my students find out, or I would lose face. So, every time I need to call a student's name, I refer to the student I know who is closest to them. For example, if there are 10 students:

A ? ? D ? ? ? H ? ?

When calling each student, the specific way to address them is:

Position Address
1 A
2 right of A
3 left of D
4 D
5 right of D
6 middle of D and H
7 left of H
8 H
9 right of H
10 right of right of H

Input

The input contains only one test case. The first line is the number of students $n$ ($1 \le n \le 100$). The second line gives each student's name in order from left to right, separated by spaces. Each name is either a string of at most 3 English letters or a question mark. At least one student's name is not a question mark. The next line is the number of queries $q$ ($1 \le q \le 100$). Each query contains an integer $p$ ($1 \le p \le n$), which is the position of the student to be called (the leftmost is position 1).

Output

For each query, output the address. Note that "middle of X and Y" is only used when the student being called has two nearest known students X and Y, and X is to the left of Y.

Examples

Input 1

10
A ? ? D ? ? ? H ? ?
4
3
8
6
10

Output 1

left of D
H
middle of D and H
right of right of H

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.