In the world of computing, giving gifts like arrays are completely acceptable. Instead of exchanging cards or flowers, friends here exchange prime numbers with each other. Some even walk in two-dimensional grids, rather than a quick walk in the park. Today, not for the first time, you are going to visit this unusually exceptional world.
As usual, you are greeted in the "world of computing" with two arrays and of size and respectively. Each array can be considered as a collection of elements and and are no exceptions. These two arrays contain integers in them. Delighted by this gift, you have decided to give something back to the inhabitants of this crazy world. But their test of gifts, as you have already figured, is quite extraordinary. They would only accept a gift, if the gift is related to those two given arrays.
Wondering about how a gift can be related with two arrays, you have suddenly come up with this great idea! You will ask each inhabitants 4 integers , , and , where and and give them an integer number as gift in return. Let's call each of these 4-tuple (, , , ) a query. The integer can be calculated in the following manner:
Now, given two arrays and , and a list of queries, you need to figure out what numbers are you going to give to the inhabitants as gifts.
The first line contains an integer (), the number of testcases. Each testcase starts with two integers and (), the sizes of the two arrays and respectively. The next line has integers (), where each integer indicates the -th element of the array . The following line contains integers (). Each indicates the -th element of array . The next line contains an integer (). Each of the next lines contain four integers , , and .
For each test case, first print the case number on a line by itself. After that, for each query, please print the resulting number on a line by itself.
1 2 3 1 2 1 2 3 1 1 2 1 3
Case 1: 18