#P7443. [2017年杭电多校]Journey with Knapsack

[2017年杭电多校]Journey with Knapsack

Journey with Knapsack

Problem Description

KazaQ has a knapsack with volume 2n2 \cdot n and nn kinds of food, where the ii-th food's volume is ii and the number of it is aia_i (1in)(1 \leq i \leq n) meaning that the number of the ii-th food that KazaQ would like to store into the knapsack is no more than aia_i, otherwise he would feel sick. KazaQ has a unique taste, therefore all the aia_i are distinct. KazaQ plans to make a journey but after that he needs to store some food and one piece of equipment into the knapsack. He has mm pieces of equipment, of which the ii-th piece's volume is bib_i (1in)(1 \leq i \leq n). Notice that volumes of different pieces may be the same. Assuming that two plans are distinct if and only if they contain different pieces of equipment or there exists at least one integer kk (1kn)(1 \leq k \leq n) satisfying the number of the kk-th food to store into the knapsack in this two plans are different, KazaQ is intend to know what is the total number of distinct plans for storing one piece of equipment and some food into the knapsack fully. Can you help him? The answer may be very large, so you only need to give the value of the answer modulo 109+710^9 + 7.

Input

The input contains multiple test cases. For each test case: The first line contains two positive integers nn and mm, satisfying $1 \leq n \leq 5 \cdot 10^4, 1 \leq m \leq 2 \cdot n$. The second line contains nn distinct non-negative integers a1,a2,,ana_1, a_2, \cdots, a_n, satisfying 0a1<a2<<an2n0 \leq a_1 < a_2 < \cdots < a_n \leq 2 \cdot n. The third line contains mm positive integers b1,b2,,bmb_1, b_2, \cdots, b_m, satisfying 1b1,b2,,bm2n1 \leq b_1, b_2, \cdots, b_m \leq 2 \cdot n. About 100100 test cases in total, where no more than 55 cases satisfy n103n \geq 10^3.

Output

For each test case, output " Case #xx: yy " in one line (without quotes), where xx indicates the case number starting from 11 and yy denotes the answer of corresponding case.

Sample Input

1 1

1

1

2 2

1 2

3 4

3 3

1 2 3

2 3 3

Sample Output

Case #1: 1

Case #2: 2

Case #3: 6

Source

2017 Multi-University Training Contest - Team 1