题目描述
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Watson gives to Sherlock two strings S_{1} and S_{2} consisting of uppercase English alphabets. Next he wants Sherlock to build a flower in the following way:
He puts both strings perpendicular to each other in such a way that they overlap at the same character. For example, if he has two strings "ABCDEF" and "XXBCZQ", one possible way to make a flower is:
Length of petals in the above flower are 2, 2, 3 and 3.
A flower's ugliness is sum of absolute difference of adjacent petal lengths i.e. i.e. if adjacent petal lengths are L_{1}, L_{2}, L_{3}, L_{4}, then ugliness of flower is |L_{1} - L_{2}| + |L_{2} - L_{3}| + |L_{3} - L_{4}| + |L_{4} - L_{1}|.
Sherlock wants to find minimum value of ugliness if we consider all possible flower configurations. Note that a configuration is valid even if any of the petal length is 0.
------ Input ------
First line contains T, number of test cases. Each test case consists of string S_{1} in one line followed by string S_{2} in the next line. It is guaranteed that there exists at least one possible way to make a flower.
------ Output ------
For each test case, output in one line the required answer.
------ Constraints ------
$1 ≤ T ≤ 10$
$1 ≤ length(S_{1}), length(S_{2}) ≤ 10^{5}$
----- Sample Input 1 ------
2
ABCDE
XXBCZQ
BBB
BBBBBB
----- Sample Output 1 ------
2
6
----- explanation 1 ------
Test case 1:
If we keep the configuration shown in statement, the ugliness is 2, which is minimum possible.
Test case 2:
One of the best configurations is
B
B B B B B B
B
where petal lengths are 1, 3, 1, 2.
输入格式
见题面
输出格式
见题面