

1. You can swap empty character with any adjacent character. (For example, ‘aba_ab’ can be converted into ‘ab_aab’ or ‘abaa_b’).
2. You can swap empty character with next to the adjacent character only if the adjacent character is different from next to the adjacent character. (For example, ‘aba_ab’ can be converted into ‘a_abab’ or ‘ababa_’, but ‘ab_aab’ cannot be converted to ‘abaa_b’ because ‘a’ cannot jump over ‘a’).
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘2*T’ lines represent the ‘T’ test cases.
The first line of each test case consists of a string ‘initial’ denoting the initial string.
The second line of each test case consists of a string ‘final’ denoting the final string.
For each test case, print a single integer denoting the minimum number of operations to convert the initial string to the final string.
1. Do not print anything, it has already been taken care of. Just implement the given function.
2. The string characters consist of ‘a’ ‘b’ and one ‘_’.
3. Length of the initial string is equal to the length of the final string.
1 <= T <= 25
1<= length(initial), length(final) <= 10
Time limit: 1 sec
For example, let us take the initial string ‘a_ba’ and final string ‘baa_’ a small part of the graph will look like this:
The lines in red signify the shortest path. We can clearly see that we need 3 operations to convert the initial string to the final string.
Keeping all this in mind we can design the following approach: