In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
Byteland is known for the gorgeous necklaces made by famous jeweler Byteman. These necklaces are made of gem stones threaded together. The gem stones are divided into 26 distinct sorts, these will be denoted by the lower case Latin letters: a - z (stones of the same sort are indistinguishable). It is a point of honor with Byteman never to produce two identical necklaces, therefore he keeps the descriptions of all the necklaces he had ever produced. Some of the necklaces are really long, that is why their descriptions are kept in a shorten form. Each description consists of fragments of the following form: a sequence of letters (called pattern) followed by an integer denoting the number of times the pattern repeats in the necklace. Every description is a sequence of such fragments. For example, the description:
Write a program which:
The standard input consists of two lines. Each of these lines is a description of a necklace composed of words of lower case letters from Latin alphabet and integers, separated by single spaces. The description of a necklace begins with integer equal to the number of patterns in the description, (), followed by descriptions of repeating patterns. The -th description of a repeating pattern is composed of: an integer equal to the length of the pattern, (), a word built of lower case Latin letters (a-z) representing the pattern, and an integer equal to the number of times the pattern repeats in the description, (). The sum of numbers (for ) does not exceed .
Your program should write in the first and only line of the standard output a word TAK ("YES" in Polish), if both descriptions represent the same necklace, and a word NIE ("NO" in Polish) if the described necklaces are different.
For the input data:
3 3 abc 2 3 xyz 1 3 axc 3 4 4 cabc 1 4 xyza 1 3 xca 3 1 b 1
the correct result is:
Task authors: Adam Malinowski, Wojciech Rytter.