Time limit: 2s
            Memory limit: 64MB
            Input: 
        Simon learned the divisibility criteria yesterday at school, and being a very smart student, Georgescu gave him an interesting problem he had been thinking about since his youth.
Task
Given the set of digits , answer  questions of the form:
How many numbers with  digits formed only from the digits in set  have a remainder of  when divided by .
Input data
The first line contains the number , and the next lines contain two natural numbers and .
Output data
Print natural numbers, each on a new line, representing the answer to each question in order.
Constraints and clarifications
- Since the answer can be very large, Simon will only tell Georgescu the remainder when it is divided by .
- .
- .
- Clearly, .
| # | Points | Constraints | 
|---|---|---|
| 1 | 11 | |
| 2 | 20 | |
| 3 | 41 | |
| 4 | 28 | No other restrictions | 
Example
stdin
3
2 0
3 1
5 2
stdout
6
21
341
Explanation
For  and , the convenient numbers are: , , , , , .
There are  numbers with  digits formed from the digits in set  that are divisible by .
The remainder of  divided by  is .