permutations-of-salt-and-pepper

You are given two arrays A and B which are permutation of first n numbers.

You need to make both arrays magical.Two Arrays A and B are magical when for each valid position i, A[i] = B[i].

Operations allowed (only on array A) are
Salt: Change any number of array A to any number you wish with cost x.
Pepper: Rotate array A left by 1 position with cost y. i.e. 
change {A[1],A[2],A[3],...,A[n]} to {A[2],A[3],...A[n],A[1]} with cost y.

You need to print minimum cost to make both arrays magical.

Input Format:
First line contains T i.e. number of test cases. 1 ≤ T ≤ 25
First line of each test case contains N, size of array. 1 ≤ N ≤ 10^5
Second line contains two space separated integers x and y. 1 ≤ x ≤ 100 and 1 ≤ y ≤ 100
Third line contains n space separated integers where i'th integer = A[i]
Fourth line contains n space separated integers where i'th integer = B[i]
It is guaranteed that both array A and B are some permutation of first N Numbers. 

Output Format:
For each test case, print (minimum cost % 1000000007) in a single line without any spaces.

Author : Sumeet Varma

SAMPLE INPUT
2
2
3 4
1 2
2 1
4
3 5
1 2 3 4
2 3 4 1

SAMPLE OUTPUT
4
5

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: