TEX 2 Unicode
In many modern applications, the two-byte character set known as Unicode is utilized. Unlike the one-byte ASCII, where each character is represented by a single byte, Unicode uses two bytes per character. This allows Unicode to represent up to 65536 different characters, accommodating a wide range of alphabets without overlap.
Despite this, most text processing systems still rely on ASCII for historical reasons. This reliance causes issues with characters from various national alphabets, as the same ASCII code can correspond to different symbols in different encodings.
To address this issue, developers of text processing systems have introduced various code sequences to represent characters from national alphabets. In this task, you are required to convert text formatted for the T_EX system into Unicode. Note that the model used in this task is simplified and may not fully reflect real-world scenarios.
In T_EX, the command \IeC is used to include a character from a national alphabet in the text. Each national alphabet character corresponds to a specific sequence of Latin letters. For instance, the Russian letter "п" is represented by the sequence \cyrp, which is enclosed in curly braces following the command \IeC. Therefore, to include the letter "п" in the text, you would write \IeC{\cyrp}. Note that spaces are not permitted within the code sequence.
You are provided with a text formatted in the T_EX style. Your task is to output the sequence of Unicode codes for the characters in the text to an output file. All recognized national alphabet characters should be converted to their corresponding Unicode characters. Other characters, as well as sequences that correspond to unknown characters, should be output unchanged. When converting from ASCII to Unicode, the higher byte of the two-byte character becomes 0. Some code sequences may be incorrect (e.g., contain spaces or otherwise not conform to the format) and should also be output unchanged.
Input
The first line contains the number N – the number of known national alphabet characters (1 ≤ N ≤ 100). The next N lines list the code sequences for these characters along with their corresponding Unicode character codes (given as a 2-byte number in 16-base notation, written as 4 characters), separated by a single space. All code sequences begin with the character "\", followed by no more than 10 Latin letters. After the code sequences, the text that needs to be processed is provided. Ignore line breaks (but not in code sequences).
Output
Output the sequence of Unicode codes for the characters that will form the transformed file. Each code should be a 16-base number, padded with leading zeros to 4 characters if necessary. The numbers should be separated by spaces and/or line breaks.