

‘N’ = 4, ‘top’ = {3, 5, 3, 1}, ‘bottom’ = {2, 3, 5, 3}.
Now in this example, if Ninja rotates the second and the fourth dominos, the top row will be {3, 3, 3, 3}. Hence the answer is 2.
The first line of input format contains ‘T’, denoting the number of test cases. Then each test case follows.
The first line of each test case contains an integer ‘N’, denoting the number of dominos.
The second line of the test case contains an array of ‘N’ integers denoting the ‘top’ array.
The third line of the test case contains an array of ‘N’ integers denoting the ‘bottom’ array.
For each test case, print a single integer denoting the minimum number of rotations required.
Output for every query will be printed in a separate line.
You are not required to print anything explicitly. It has already been taken care of. Just implement the functions.
1 <= T <= 10
1 <= ‘N’ <= 2 * 10^5
1 <= ‘top[i]’, ‘bottom[i]’ <= 6
Time Limit: 1 second
As the numbers are only from 1 to 6, we can check for every number whether the number is present in all the ‘N’ dominos at least on one side or not. If the current number is present on all the ‘N’ dominos we will then calculate the minimum rotations needed to make either the top or the bottom row the same.
The steps are as follows: