Spell
Troll Vol'jin is on a quest to discover the most effective healing spells. He aims to blend ancient spells with contemporary healing magic research to create spells that heal faster than any known ones. Vol'jin has selected N spells from ancient texts. He desires his new spell to be a common substring of all these ancient spells. This means that whenever any of the ancient spells are recited, Vol'jin's new spell will also be recited. To simplify recording, the troll encodes spells using lowercase Latin letters. There may be multiple spells that are common to all the chosen ancient spells, so Vol'jin doesn't require you to find them all. Instead, he asks you to provide certain spells based on their lexicographical order.
Your task is to identify the spells requested by Vol'jin.
Input
The first line of the input contains a single number N (1 ≤ N ≤ 20), representing the number of ancient spells Vol'jin has selected. This is followed by N lines, each describing a spell as a string of lowercase Latin letters. The total length of all these descriptions combined does not exceed 10^5. After this, a number M is given, indicating how many spells Vol'jin wants to retrieve. Following this are M lines, each containing one number, which represents the lexicographical position (starting from one) of the spell Vol'jin wishes to obtain. It is guaranteed that this position does not exceed the total number of valid spells.
Output
For each request, output the corresponding spell on a separate line. It is guaranteed that the total length of all output spells will not exceed 10^5.