#P1506C. Double-ended Strings
Double-ended Strings
Description
You are given the strings and , consisting of lowercase Latin letters. You can do any number of the following operations in any order:
- if (the length of the string is greater than zero), delete the first character of the string , that is, replace with ;
- if , delete the last character of the string , that is, replace with ;
- if (the length of the string is greater than zero), delete the first character of the string , that is, replace with ;
- if , delete the last character of the string , that is, replace with .
Note that after each of the operations, the string or may become empty.
For example, if "hello" and "icpc", then you can apply the following sequence of operations:
- delete the first character of the string "ello" and "icpc";
- delete the first character of the string "ello" and "cpc";
- delete the first character of the string "ello" and "pc";
- delete the last character of the string "ell" and "pc";
- delete the last character of the string "ell" and "p".
For the given strings and , find the minimum number of operations for which you can make the strings and equal. Note that empty strings are also equal.
The first line contains a single integer (). Then test cases follow.
The first line of each test case contains the string (), consisting of lowercase Latin letters.
The second line of each test case contains the string (), consisting of lowercase Latin letters.
For each test case, output the minimum number of operations that can make the strings and equal.
Input
The first line contains a single integer (). Then test cases follow.
The first line of each test case contains the string (), consisting of lowercase Latin letters.
The second line of each test case contains the string (), consisting of lowercase Latin letters.
Output
For each test case, output the minimum number of operations that can make the strings and equal.