Each student can take many subjects. Each subject can be taken by many students. Simulate the process of taking the subject.
First line contains number n. Each of the next n lines have the form: Subject Student's_Surname. It means that subject Subject was taken by student with given surname. Then given number of queries q. Each of the next q lines contains either subject or surname.
If the query contains subject, print in one line in acceding order the surnames of the students who took this subject. If the query contains surname, print in one line in acceding order the subjects taken by this student.