Under construction

Still being built. Things may change

Phone Friends

Time limit1sMemory limit1024 MB

Summary
Count ordered distributions of K identical candies to N friends where each friend gets between m and M candies, modulo 1e9+7.
Level

Hard8 of 10

Topics
Dynamic programming, Combinatorics, Prefix sum, Math
Solved
No attempts yet

Problem

Yunje, exhausted from delivering candy, came home and went to bed.

In a dream as sweet as candy, Yunje made imaginary friends called "phone friends." Phone friends love candy, but they never ask for a candy delivery. Instead, they come to Yunje directly, so he can just stand still and hand out the candy!

In the dream, Yunje wants to distribute KK candies of the same kind among NN phone friends, giving out all of them. The phone friends will not leave Yunje no matter how the candy is distributed, but each wants to receive at least mm candies. Also, no friend wants anyone other than themselves to receive more than MM candies.

Yunje has at least NmNm and at most NMNM candies. Find the number of ways Yunje can distribute the candy while satisfying all the phone friends.

Input

The first line gives the integers NN, mm, MM, KK. (2≤N≤1 0002 \leq N \leq 1\ 000, 0≤m≤M≤1 0000 \leq m \leq M \leq 1\ 000, Nm≤K≤NMNm \leq K \leq NM)

NN is the number of phone friends and KK is the number of candies Yunje has. mm is the minimum number of candies each friend must receive, and MM is the maximum number of candies each friend can receive.

Output

Print the number of ways Yunje can distribute the candy to the phone friends while satisfying the conditions. There may be too many ways, so print the number of ways modulo 109+710^9+7.

Examples2

  1. Example 1

    Input
    2 0 4 4
    
    Expected output
    5
    
  2. Example 2

    Input
    2 1 4 4
    
    Expected output
    3