Big Orange Cat (大橘) loves doing puzzles. He has n types of puzzles, and each puzzle i can be represented by a string Ai composed of all visible characters from the ASCII code.
Unfortunately, he messed up the puzzles. What a baganono... Now for each puzzle i, he has found some puzzle pieces, represented by a string Bi. You can choose any interval li, ri, and select some puzzle pieces from B[li]
to B[ri]
. If it's possible to rearrange these pieces to form Ai, then this interval [li, ri] is called a 'valid interval'.
Your task is to find a valid interval that meets the following conditions:
After finding a valid interval that meets these conditions, tell Big Orange Cat which positions within this interval he should take puzzle pieces from to form Ai. However, there might be many ways to do this, and since Big Orange Cat is very lazy, please output the lexicographically smallest method. If there's no valid interval at all, output 'baganono'.
Important: The method for comparing the lexicographic order of two strings is as follows: Starting from the first position (leftmost), find the first character that differs. The string with the smaller character at that position is considered lexicographically smaller. For example, "abc" < "abd" because the first differing letter 'c' < 'd'.
BUT!!: The lexicographically smallest solution for this problem refers to the lexicographically smallest sequence of indices chosen. The comparison logic is similar to that used for characters, but instead applies to entire integers (e.g., [1, 2, 3] < [1, 3, 3], [1, 2, 3] < [1, 11, 111]).
The first line of input contains an integer n. n represents the number of puzzle-instruction manual pairs.
The following n lines each contain two strings, Ai and Bi, separated by a space. They represent the i-th puzzle and instruction manual, respectively.
Output the answer for each pair of Ai and Bi in sequence. The answer may have two possible situations:
[B[li], B[ri]]
to form Ai. Output these in ascending order (assuming the answer is x1, x2, x3, ..., then x1 < x2 < x3 < ...)."baganono"
(without quotes)Please remember to print "\n" at the end, and dont print space (" ") at the end of every line.
Explanation of sample I/O:
2 4 7
.baganono
.1 2 3
.