You are given two arrays and of length and respectively. You can perform the following operation any number of times on and .
You want to make and equal. Find the maximum possible length of arrays and such that is equal to . If it is impossible to make and equal then print .
Input format
Output format
For each test case, print the maximum possible length of arrays and such that is equal to . If it is impossible to make and equal then print in a new line.
Constraints
For test case : It can be proven that we cannot make and equal. Hence, the answer is .
For test case : We can perform operations on from index 1 to 2 and from index 4 to 5 (1-based indexing).
and after performing the operation is [4, 2, 5]. The maximum possible length is .