Monster Hunter
题号:NC222761
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Ema is the best carry player in a game. In the game, she needs to eliminate monsters. The i-th monster has h_i health points (HP) at the beginning. When a monster is attacked by Ema, its HP is reduced by her attack power. When the HP of a monster is less than or equal to 0, the monster is eliminated.

To make the game more interesting, the attack power is not a constant number. There is a basic attack sequence , and the damage caused is generated by repeating this sequence. Formally, let r_i be the damage caused by the -th attack, we have

To eliminate the monsters as soon as possible, Ema wants to minimize the number of attacks. Can you tell her the minimum number of attacks required to eliminate all the monsters?

输入描述:

There are multiple test cases. The first line of the input contains an integer  indicating the number of test cases. For each test case:
The first line contains an integer () indicating the length of the basic attack sequence.
The second line contains integers () indicating the basic attack sequence.
The third line contains an integer () indicating the number of monsters.
The fourth line contains integers () where h_i indicates the initial HP of the -th monster.
It's guaranteed that neither the sum of n nor the sum of m of all test cases will exceed .

输出描述:

For each test case output one line containing one integer indicating the minimum number of attacks to eliminate all the monsters.
示例1

输入

复制
2
2
3 2
3
2 4 2
5
1 2 3 2 1
2
3 3

输出

复制
4
3

备注:

For the first example, the damage sequence is . We can attack monsters 1, 2, 3 and 2 in order to eliminate all the  monsters. 
For the second example, we can attack monsters in order.