Timer is Running

Transform String
##### Submissions: 10930   Accuracy: 18.41%   Difficulty: Medium   Marks: 4

You are provided two strings A and B. You have to transform string A into string B in minimum number of steps. Only one operation is allowed, chose any of the characters in string A and place it in the front of A. If its not possible to transform string A into string B then print -1 otherwise print the minimum number of steps required.

Note: All the characters in the string are lowercase English characters.

Input :

The first line contains integer T, denoting number of test cases. Then T test cases follow .
The first line of each test case contains two space separated  strings A and B.

Output:
Print in a new line the answer of each test case .

Constraints :

1<=T<=100

1<=|A|,|B|<=10^5

Example:
Input:

2

Output :
1
2

Explanation:
Test Case 1:

Move 'a' in "bcad" at the start of it. Hence, we now have "abcd" which is equivalent to the second string. Hence, minimum number of steps = 1
Test Case 2:
Move 'b' in "abdd" at the start of it. Hence, we noe have "badd".
Move 'd' at the start. Hence, we now have "dbad" which is equivalent to the second string.
Hence, minimum number of steps = 2

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: Sonesh Shukla

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.