To solve this problem, you need to first go through (not necessarily solve) the one with the encyclopaedia.
Upon reaching the beach house, Joey realized that he has made a huge mistake. He was prepared to read the encyclopaedia which you had helped him to locate earlier. But he had almost forgot that they were not going to stay for a single day, but multiple days - and so now he needs to read all the books to match level for each day!
Now Joey is a really nice guy, so he doesn't want to trouble you much. So he has decided to find out the value himself, but just to make sure - he has asked you the sum of all such position during the day of their stay at the beach house.
Input
First line contains number of test cases T. The first line of each testcase contains a positive integer N - the number of encyclopaedias. The second line contains N space-separated positive integers li representing the level of encyclopaedia at the ith position. Note that there can be many encyclopaedias with same level. The next line contains a positive integer D, denoting the number of days Joey stays with his friends at the beach house. The last line contains D positive numbers Li which denote the level of encyclopaedia just above the one Joey has to read on day Di.
Output
Output a single positive number pointing to the sum of all the maximum position i of the encyclopaedia just below the level Joey has to read on the day Di. In case, the level doesn't exist, add 0.
Constraints
0 < T <= 10
0 < N, D <= 100000 (105)
0 < li, Li <= 1000000 (106)