#P16741. [GKS 2019 #G] Book Reading

[GKS 2019 #G] Book Reading

Problem Description

Supervin is a librarian handling an ancient book with NN pages, numbered from 1 to NN. Since the book is too old, unfortunately MM pages are torn out: page number P1P_1, P2P_2, ..., PMP_M.

Today, there are QQ lazy readers who are interested in reading the ancient book. Since they are lazy, each reader will not necessarily read all the pages. Instead, the i-th reader will only read the pages that are numbered multiples of RiR_i and not torn out. Supervin would like to know the sum of the number of pages read by each reader.

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case begins with a line containing the three integers NN, MM, and QQ, the number of pages in the book, the number of torn out pages in the book, and the number of readers, respectively. The second line contains MM integers, the i-th of which is PiP_i. The third line contains QQ integers, the i-th of which is RiR_i.

Output Format

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the total number of pages that will be read by all readers.

3
11 1 2
8
2 3
11 11 11
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
1000 6 1
4 8 15 16 23 42
1
Case #1: 7
Case #2: 0
Case #3: 994

Hint

In sample case #1, the first reader will read the pages numbered 2, 4, 6, and 10. Note that the page numbered 8 will not be read since it is torn out. The second reader will read the pages numbered 3, 6, and 9. Therefore, the total number of pages that will be read by all readers is 4+3=74 + 3 = 7.

In sample case #2, all pages are torn out so all readers will read 0 pages.

In sample case #3, the first reader will read all the pages other than the six given pages.

Limits

1T1001 \le T \le 100.

1P1<P2<...<PMN1 \le P_1 < P_2 < ... < P_M \le N.

1RiN1 \le R_i \le N, for all i.

Test set 1 (Visible)

1MN10001 \le M \le N \le 1000.

1Q10001 \le Q \le 1000.

Test set 2 (Hidden)

1MN1051 \le M \le N \le 10^5.

1Q1051 \le Q \le 10^5.