Company: Nk securities
Difficulty: medium
String Transformation Problem Description You are given two strings a and b made up of uppercase and lowercase English letters. In a single move you may choose two characters x and y and replace every occurrence of x in a with y. Decide whether repeating this move any number of times (including zero) can turn a into b, and if it can, report the fewest moves that accomplish it. Input Format The first line contains an integer t, the number of test cases. For each test case: The first line contains the string a. The second line contains the string b, the intended final state of a. Constraints 1 ≤ |a| = |b| ≤ 10 5 The sum of lengths of all strings across all test cases does not exceed 10 5 . Strings consist of only uppercase and lowercase English letters. Output Format For each test case, output on a new line: -1 if the conversion is not possible. Otherwise, print the minimum number of transformations required. Examples Sample Input: 3 BBC ABC abcd bacd problem answers Sample Output: