#P4290. [HAOI2008] 玩具取名
[HAOI2008] 玩具取名
Description
Someone has a set of toys and wants to give them names. First, he chooses any one letter from W, I, N, G as the base name of a toy. Then, according to his preference, he can replace any letter in the current name with any allowed pair of letters from W, I, N, G, so that the name can grow very long.
Now, given a very long name, he wants you to guess which initial letters it could have been derived from.
Input Format
The first line contains four integers , indicating how many different pairs of letters each letter can be replaced by.
The next lines each contain two letters, indicating that W can be replaced by these two letters.
The next lines each contain two letters, indicating that I can be replaced by these two letters.
The next lines each contain two letters, indicating that N can be replaced by these two letters.
The next lines each contain two letters, indicating that `G$ can be replaced by these two letters.
The last line contains a string of length , representing the toy’s name.
Output Format
Output a single line string listing the letters from which the given name could have been derived (in the order W, I, N, G). If the given name cannot be derived from any letter, output The name is wrong!.
1 1 1 1
II
WW
WW
IG
IIII
IN
Hint
Constraints
- of the testdata satisfies , .
- of the testdata satisfies , .
Translated by ChatGPT 5
京公网安备 11011102002149号