#P10947. [2015杭电多校]MZL's Circle Zhou

[2015杭电多校]MZL's Circle Zhou

MZL's Circle Zhou

Problem Description

MZL's Circle Zhou is good at solving some counting problems. One day, he comes up with a counting problem: You are given two strings a,ba,b which consist of only lowercase English letters. You can subtract a substring xx (maybe empty) from string aa and a substring yy (also maybe empty) from string bb, and then connect them as x+yx+y with xx at the front and yy at the back. In this way, a series of new strings can be obtained. The question is how many different new strings can be obtained in this way. Two strings are different, if and only if they have different lengths or there exists an integer ii such that the two strings have different characters at position ii.

Input

The first line of the input is a single integer T (T5)T~(T≤5), indicating the number of testcases. For each test case, there are two lines, the first line is string aa, and the second line is string bb. 1<=a,b<=900001<=|a|,|b|<=90000.

Output

For each test case, output one line, a single integer indicating the answer.

Sample Input

2
acbcc
cccabc
bbbabbababbababbaaaabbbbabbaaaabaabbabbabbbaaabaab
abbaabbabbaaaabbbaababbabbabababaaaaabbaabbaabbaab

Sample Output

135
557539

Author

SXYZ

Source

2015 Multi-University Training Contest 5