In cryptography, a Caesar cipher, also known as Caesar’s ci- pher, the shift cipher, Caesar’s code or Caesar shift, is one of the simplest and most widely known encryption tech- niques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet (wrapping around in the end). For example, given an alphabet of capital let- ters in usual order, with a shift of 3, A would be replaced by D, B would become E, and so on, with Z being replaced by C. The method is named after Julius C Caesar, who used it in his private correspondence. We are given an alphabet A, a string S which is en- crypted using a shift cipher and a plaintext word W . Find the possible values of shifts (in the range [0, |A| − 1]) used in encryption if we know that the unencrypted text contains exactly one occurrence of the word W. Input Input starts with an integer N on a line, the number of test cases. Each cases contains three strings on separate lines, alphabet A, plaintext word W and encrypted text S. Alphabet A will contain only letters and digits ([‘A’-‘Z’][‘a’-‘z’][‘0’-‘9’]) and its symbol order is not necessarily lexicographical (see the third sample case). A will not contain duplicate symbols. The constraints are as given: 3 ≤ |A| ≤ 62, 1 ≤ |W| ≤ 50,000, 3 ≤ |S| ≤ 500,000. Output For each test case print one line of output. If there are no shifts that would satisfy the condition of W being a part of the unencrypted S, print ‘no solution’. Ifthereisexactlyoneshiftthatcouldhavebeenused,print‘unique: #’where#istheshiftvalue. It there are more than one possible shifts print ‘ambiguous: ’ followed by the sorted list of shift values. For clarification, see the sample output. Sample Input 4 ABC ABC ABCBBBABC ABC ABC ABCBCAABC D7a D7a
2/2 D7aaD77aDD7a ABC ABC ABC Sample Output no solution unique: 1 ambiguous: 1 2 unique: 0