The Still Embarrassed Cryptographer

No attempts yetTime limit1sMemory limit256 MB

Problem

The cryptographer Borge is writing a new security module for his company. Nobody could read his code in the previous module and it caused a lot of trouble, so his boss told him to keep this one much simpler.

The secret key cc is a one to one map from the 26 uppercase letters onto the 26 uppercase letters. For a string S=s1s2smS = s_1 s_2 \dots s_m the module computes crypt(S)=c(s1)c(s2)c(sm)\mathrm{crypt}(S) = c(s_1) c(s_2) \dots c(s_m), and the decryption key c1c^{-1} satisfies c1(c(s))=sc^{-1}(c(s)) = s.

The scheme has a weakness. For some qq the identity cryptq(crypt(S))=S\mathrm{crypt}^q(\mathrm{crypt}(S)) = S holds, so an attacker only has to keep encrypting the ciphertext until readable text appears. A small qq is dangerous, so Borge needs qq first.

You are given a plaintext SS and the matching ciphertext T=crypt(S)T = \mathrm{crypt}(S). Here qq is the smallest non-negative integer such that applying crypt\mathrm{crypt} to TT another qq times gives SS back.

The pair SS and TT reveals the value of cc only on the letters that occur in SS, and the images of the other letters stay unknown. If every key cc that agrees with SS and TT gives the same qq, print that value. If the value of qq depends on the key, print mjau.

Input

The first line has the number of test cases nn (1n1001 \le n \le 100). Each test case consists of two lines, the plaintext SS on the first line and the ciphertext TT on the second. At least one key satisfies crypt(S)=T\mathrm{crypt}(S) = T. Both strings use only the uppercase letters 'A' to 'Z', and 1S=T10001 \le |S| = |T| \le 1000. The encryption function cc is different in each test case.

Output

For each test case print qq on its own line. If SS and TT alone do not determine qq, print mjau.