Math Class Purge

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem types

At Thornhill Secondary school, only the best of the best may be accepted and enrolled into Mr Fraschetti's advanced placement mathematics class. As such, Mr Fraschetti purges those he believes are not qualified to be in the class at the beginning of each semester. Given the list of students who wish to enrol in the class and the purges that Mr Fraschetti makes, determine the final class list in the order of when the students applied.

Input Specification

The first line of input contains n (1 \le n \le 50000) representing the number of students who wish to enrol in the class.
The next n lines each contain n_i, the name of the person who wants to join the class. Their name will be all lowercase letters. The names are given in order of when they applied so that the n_i student applied after the n_{i-1} student and before the n_{i+1} student.
The next line contains k (1 \le k \le n) representing the number of people Mr Fraschetti will remove from the class.
The next k lines will contain an integer k_i (0 \le k_i \le n) representing the index of the student to be removed in relation to the original list, where the first name is at index 0.

Output Specification

Output each remaining student on a new line in the order of when they applied from earliest to latest.

Sample Input


Sample Output


Explanation for Sample Data

In the beginning, 4 people applied to the AP class. jonathansumabat applied first, followed by donaldtrump then narwhal and potato. Mr Fraschetti purged 2 of these students. First he purged the least competent of them, jonathansumabat at index 0. Then, of the remaining 3 students he purged the one at index 3 where in relation to the original list of 4 students, is potato. In the end, donaldtrump and narwhal remain in the class.


There are no comments at the moment.