Given a natural number and different coin values , compute in how many ways it is possible to achieve change by using each value at most twice. Here, two coins with the same value are considered different.
For example, if and the available values are and , then there are three ways to achieve it: , , and also .
Input consists of several cases. Every case begins with and , followed by . Assume , , and that all are different.
For every case, print the number of ways to exactly achieve change by using each value at most twice. Since the result can be huge, make the computations modulo .
Input
4 2 1 2 400 1 200 400 1 300 5 3 4 2 1 5 5 1 2 3 4 5 120 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Output
3 1 0 6 14 36982290