Let's get straight into the problem. In ths problem, here will be multiple test cases. In each test case you will be given an array of integers. Then there will be queries. In each query You will be given an integer . For every where you have to change to mod . After executing all queries you have to print the array in the order of input.
Note that you have to execute queries in the order of input.
Input will start with a single integer (), denoting the number of test cases.
For each test case, the first line will contain an integer (). is the size of the array .
Second-line will contain space-separated integers in the range .
Third line will contain an integer (). is the number of queries. Fourth line will contain integers in the range . Each of the integers are the explained in the statement.
It is guaranteed that sum of total over all test cases doesn't exceed 500000 and the sum of total over all test cases doesn't exceed 500000.
For each test case print "Case x:" in a line without quotations where x is the test case number.
Then print the elements of array separated by spaces. See sample input-output for better understanding.
Input | Output |
---|---|
2 2 4 4 1 2 3 8 4 8 1 2 | Case 1: 0 0 Case 2: 0 0 0 |