The government wants to provide relief to the flood-affected people. So, it set a committee. The committee has created a function to count the number of affected people.
Suppose, the country has divisions . means the first division has districts. means the second division has districts.
In general, means the division has districts.
They defined the function F such that where , . It means the division has affected people.
If they wanted to do the calculation by hand, it would have taken a lot of time. So, they decided to create a robot. If they give the robot, , (), and (), the robot returns .
As they are not experts, the robot has some errors. It can calculate a number x if and only if and it calculates the numerator first and then divide it with denominator.
If it takes a number Y and can’t calculate , it assumes that . But as the committee members are not sure whether the robot works properly, they hired you as you are an expert mathematician. Can you help them?
In the problem:
means Pi function.
means floor function. It returns the largest integer that is smaller than or equal to .
means Sigma function.
It is guaranteed that .
Input starts with an integer (), denoting the number of test cases. The first line of each test case contains one integer () the number of divisions in the country. The second line of each test case contains integers (), where is the number of districts in division.
The third line of each test case contains one integer (). The fourth line of each test case contains integers . All indices are 1-based.
For each case print the case number and the the value of .
Input | Output |
---|---|
1 10 100 10 10 10 10 10 10 10 10 10 2 1 2 | Case #1: 100000 |
Here, , and Now, suppose and then So Again As not belongs to , it cant calculate So robot assumes that So the final answer is |