Hongjun likes strings, so he keeps making up problems about them.
Here is one of them. Given a string S and two strings A and B, find the shortest contiguous substring of S that contains both A and B as substrings. The occurrence of A and the occurrence of B are allowed to overlap.
Hongjun is smart, so he solved that at once. Then he thought of a harder version, in which the two strings A and B arrive as Q separate questions. He could not find a fast way to answer them, so he decided that short A and B would let him solve it quickly.
Help Hongjun and write a program that answers every question.