PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000091. Lập kế hoạch viết mã (Writing Code)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Lập kế hoạch viết mã (Writing Code)

Writing Code

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A software project requires exactly mm lines of code. There are nn programmers. Every line written by programmer ii introduces exactly aia_i bugs.

A plan is a sequence of nonnegative integers (v1,v2,…,vn)(v_1,v_2,\ldots,v_n) where viv_i is the number of lines assigned to programmer ii. A plan is good if:

$$\sum_{i=1}^{n}v_i=m,\qquad \sum_{i=1}^{n}v_i a_i\le b.$$

Two plans differ if at least one programmer receives a different number of lines. A programmer may be assigned zero lines or any positive number of lines, provided the total is exactly mm. Programmers with the same bug rate are still distinct people; swapping their assignments may yield distinct plans.

Count good plans modulo the supplied positive integer mod. The modulus need not be prime, and modular division is unnecessary. If mod=1, the result is zero.

Input

The first line contains four integers n,m,b,modn,m,b,mod. The second line contains nn integers a1,…,ana_1,\ldots,a_n, the per-line bug counts.

Output

Print one integer: the number of good plans modulo mod.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤121\le n,m\le12, 0≤b≤250\le b\le25, 0≤ai≤250\le a_i\le25, 1≤mod≤109+71\le mod\le10^9+7.

  • Subtask 2 (30 points): 1≤n,m≤1001\le n,m\le100, 0≤b≤1000\le b\le100, 0≤ai≤1000\le a_i\le100, 1≤mod≤109+71\le mod\le10^9+7.

  • Subtask 3 (50 points): 1≤n,m≤5001\le n,m\le500, 0≤b≤5000\le b\le500, 0≤ai≤5000\le a_i\le500, 1≤mod≤109+71\le mod\le10^9+7.

Examples

Example 1

Input

3 3 3 100
1 1 1

Output

10

Explanation: Each line causes one bug, so every plan with three lines has three bugs. The number of nonnegative solutions to v1+v2+v3=3v_1+v_2+v_3=3 is inom{5}{2}=10.

Example 2

Input

2 2 1 1000
0 1

Output

2

Explanation: The three two-line plans are (2,0),(1,1),(0,2)(2,0),(1,1),(0,2). The last has two bugs and is invalid. Thus there are two good plans.