Leet

Leet is an alternative English alphabet used mostly on the Internet. Each character in the English alphabet is replaced by one or more characters which look similar to the original one. For example, the phrase “ACMICPC” can be written as “4(|V|1(|>(” in Leet by replacing ‘A’ with ‘4’, ‘C’ with ‘(’, ‘M’ with ‘|V|’, ‘I’ with ‘1’, and ‘P’ with ‘|>’. Note that three symbols ‘|V|’ were used to represent a symbol ‘M’ and two symbols ‘|>’ for ‘P’. There may be more than one way to represent an English character. For example, ‘[)’, ‘|)’, and ‘|>’ may represent ‘D’. While interesting, Leet can be very confusing and hard to read. Given one sentence in the Standard English alphabet and another in Leet, write a program to decide whether they are the same or not under the following rules. a) Each character in the Standard English alphabet is mapped to up to k characters in Leet. The value of k is known in advance. b) For each character in the Standard English alphabet, there is only one way to represent it in Leet. For example, once ‘D’ is mapped to ‘[)’, then you cannot use ‘|>’ to represent ‘D’ within the same phrase. But two or more characters of the Standard English alphabet can be mapped to the same sequence of symbol(s) in Leet. For example, both ‘D’ and ‘P’ can be mapped to ‘|>’ simultaneously. An English character and its Leet representation do not need to look similar to each other. Input Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case consists of three lines. The first line of each test case contains one integer k (1 ≤ k ≤ 3) which is the maximum number of characters in Leet for one Standard English alphabet. The second line of each test case contains a phrase in Standard English whose length is between 1 and 15, inclusive. It is written in English lowercase ‘a’-‘z’. The third line contains a phrase in Leet whose length is equal to or greater than 1. It is written in printable symbols ‘a’-‘z’, ‘A’-‘Z’, ‘0’-‘9’, ‘@’, ‘\’, ‘/’, ‘-’, ‘=’, ‘^’, ‘|’, ‘[’, ‘]’ , ‘(’, ‘)’ , ‘{’, ‘}’, ‘<’, and ‘>’. Output Your program is to write to standard output. Print exactly one line for each test case. The line should contain either ‘0’ or ‘1’. Print ‘1’ if two input strings are the same. Otherwise print ‘0’. The following shows sample input and output for two test cases. Sample Input 2 3 mississippi nni55i55ippi 2 foobar |=o08ar

2/2 Sample Output 1 0