CF444D DZY Loves Strings

Description

DZY loves strings, and he enjoys collecting them. In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh. Once DZY found a lucky string $ s $ . A lot of pairs of good friends came to DZY when they heard about the news. The first member of the $ i $ -th pair has name $ a_{i} $ , the second one has name $ b_{i} $ . Each pair wondered if there is a substring of the lucky string containing both of their names. If so, they want to find the one with minimum length, which can give them good luck and make their friendship last forever. Please help DZY for each pair find the minimum length of the substring of $ s $ that contains both $ a_{i} $ and $ b_{i} $ , or point out that such substring doesn't exist. A substring of $ s $ is a string $ s_{l}s_{l+1}...\ s_{r} $ for some integers $ l,r $ $ (1

Input Format

N/A

Output Format

N/A

Explanation/Hint

The shortest substrings in the first sample are: xyz, dyhduxyz. The shortest substrings in the second sample are: ca, abc and abd. The shortest substrings in the third sample are: baabca and abaa.