Tommy has a multiset of positive integers
and
queries. In query
, he has
prime numbers
and asks: how many multisets
satisfy that all given primes
divide the product of all elements of
? Output the answer modulo
.
Constraints
Test | Other restrictions | |||
---|---|---|---|---|
1, 2 | ||||
3, 4, 5 | None | |||
6, 7, 8 | ||||
9, 10, 11 | ||||
12, 13 | None | |||
14, 15, 16, 17 | None | |||
18, 19, 20 | None |
Input Specification
The first line contains a positive integer .
The second line contains positive integers
.
The third line contains a positive integer .
The next lines begin with a positive integer
.
primes follow, describing a query.
Output Specification
Output lines, corresponding to the answer for the corresponding query.
Sample Input 1
5
10 2 10 5 46
4
2 2 5
2 2 23
1 3
1 23
Sample Output 1
27
16
0
16
Attachments
Attachments can be found here.
Comments