#P4470. [BJWC2018] 售票
[BJWC2018] 售票
Description
A new type of automatic ticket machine has appeared at the train station in city C. When buying a ticket, the passenger first enters the destination name on the machine. There are destinations in total. As the passenger types each letter in order, the number of candidate destinations gradually decreases.
On the machine screen, there is a keyboard with rows and columns, as shown in the figure below.

After each letter is entered, only the valid characters on the keyboard are selectable (depending on the remaining candidate destinations), and the other letters are replaced by the character *.
Given the names of destinations and the characters already typed by the passenger, output the current state of the keyboard.
Input Format
The first line contains an integer (). The next lines each contain a string of uppercase English letters with length at most , representing a destination. The last line contains a string with length at most , representing the characters typed in order.
Output Format
Output lines, each being a string of length , representing the keyboard state.
4
ZAGREB
SISAK
ZADAR
ZABOK
ZA
****B*D*
*G******
********
********
Hint
Sample explanation:
After typing ZA, the next character could be G (the destination could be ZAGREB), or D (the destination could be ZADAR), or B (the destination could be ZABOK).
Translated by ChatGPT 5
京公网安备 11011102002149号