Company: Nk securities
Difficulty: medium
String Transformation Problem Description You are given two strings a and b consisting of uppercase and lowercase English letters. In one move, you can pick two characters x and y and transform all occurrences of x in a to y. Find whether it is possible to convert a into b using the above operation multiple times (possibly none). If yes, also find the minimum possible number of transformations required. 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 pro