AT_abc430_e [ABC430E] Shift String

Description

You are given strings $ A $ and $ B $ of equal length consisting of `0` and `1`. You can perform the following operation on $ A $ zero or more times. - Move the first character of $ A $ to the end. Find the minimum number of operations required to make $ A=B $ . If it is impossible to make $ A=B $ no matter how you operate, print $ -1 $ instead. You are given $ T $ test cases; find the answer for each of them.

Input Format

The input is given from Standard Input in the following format: > $ T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T $ Each test case is given in the following format: > $ A $ $ B $

Output Format

Print $ T $ lines. The $ i $ -th line should contain the answer for the $ i $ -th test case.

Explanation/Hint

### Sample Explanation 1 This input contains five test cases. - For the first test case, $ A= $ `1010001` and $ B= $ `1000110`. - By performing the operation on $ A $ twice, $ A $ becomes `1010001` $ \rightarrow $ `0100011` $ \rightarrow $ `1000110`, which makes $ A=B $ . - For the second test case, no matter how you perform the operation, you cannot change `000` to `111`. - For the third test case, $ A=B $ from the beginning. ### Constraints - $ 1 \le T \le 10000 $ - $ A $ and $ B $ are strings consisting of `0` and `1`. - $ 2 \le |A|=|B| \le 10^6 $ - For a single input, the sum of $ |A| $ does not exceed $ 10^6 $ .