#K46647. Minimum Operations by Reversing Substrings

    ID: 28023 Type: Default 1000ms 256MiB

Minimum Operations by Reversing Substrings

Minimum Operations by Reversing Substrings

You are given two strings s and t of equal length. Your goal is to transform s into t by performing a number of operations. In one operation, you can choose any contiguous substring of s and reverse it. Formally, in a single operation, you can pick indices \( i \) and \( j \) (with \( 0 \le i \le j < n \)) and reverse the substring \( s[i\dots j] \), where \( n \) is the length of the string.

Find the minimum number of such operations required to convert s into t. It is guaranteed that s and t are anagrams of each other.

Example:

Input:
abc
cba

Output: 1

</p>

In the above example, by reversing the entire string "abc" you obtain "cba" in one operation.

inputFormat

The first line contains an integer T representing the number of test cases. Each test case consists of two lines: the first line contains the string s and the second line contains the string t.

It is guaranteed that for every test case, the two strings are of equal length and are anagrams of each other.

outputFormat

For each test case, output a single line containing a single integer: the minimum number of substring reversal operations required to transform s into t.

## sample
2
abc
cba
axb
xba
1

2

</p>