Autumn Cleaning (16 MiB ML!)

Time limit2sMemory limit16 MB

Summary
Count the k-element subsets of n item prices whose sum is divisible by r, modulo 10^6+3.
Level

Medium6 of 10

Topics
Dynamic programming, Combinatorics, Math, Implementation
Solved
No attempts yet

Problem

Autumn is coming, and Sophie wants to prepare for it by emptying her grandparents' basement. She wants to sell unused items, so she put a price tag on each of them (non-negotiable!) and posted the offer online. Some items may have the same price. A junk dealer contacted her quickly, and he wants to buy exactly kk items, no matter which ones (junk is junk). Unfortunately, he visited the ATM only a moment ago, so he has only a lot of rr-zloty bills ('zloty' is the Polish currency). In how many different ways can they make a trade?

Input

The first line of the input contains three positive integers n,kn, k and rr (1≤n≤1061\leq n \leq 10^6, 1≤k≤3 0001\leq k \leq 3\,000, 1≤r≤101\leq r \leq 10), denoting the number of items Sophie wants to sell, the number of items the junk dealer wants to buy, and the face value of the bills he has. The second and last line of the input contains nn positive integers a_ia\_i (1≤a_i≤1061 \le a\_i \le 10^6). These are the prices of the items Sophie wants to sell.

Output

Print a single positive integer: the remainder modulo 106+310^6+3 of the number of sets of kk items whose total price is divisible by rr.

Hint

The junk dealer can buy the first, second and fifth items, with a total price of 8+1+3=128+1+3 = 12, or the first, third and fourth items, paying 8+2+2=128+2+2=12.

Examples1

  1. Example 1

    Input
    5 3 4
    8 1 2 2 3
    
    Expected output
    2