A database keeps its data in two areas. Area0 holds every kind of data. Area1 holds exactly one kind at a time.
Reading the i-th kind of data from Area0 costs ci. Reading the data currently held in Area1 costs nothing.
You may pick any one kind of data in Area0 and copy it into Area1. The copy costs c whichever kind you pick, and it erases whatever Area1 held before. You may copy at any moment and as many times as you want, and a copy leaves Area0 unchanged.
The kinds of data to read today and their order are fixed in advance and are all given to you. Area1 starts empty.
Find the smallest total cost of reading all of the data in the given order.
The first line contains the number of test cases T.
The first line of each test case contains three integers separated by spaces: the number of reads to perform today n (1≤n≤100000), the number of kinds of data m (1≤m≤30), and the cost c (0≤c≤1000) of copying one piece of data from Area0 into Area1.
The second line contains m integers c1,c2,…,cm (1≤ci≤100) separated by spaces. ci is the cost of reading the i-th kind of data from Area0.
The third line contains n integers d1,d2,…,dn (1≤di≤m) separated by spaces. di is the kind of data that must be read i-th.
At the start every kind of data is stored in Area0 and Area1 is empty.
For each test case, print the minimum cost of reading all of the data in order, one answer per line.