Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kombinatorika-jamoa-tuzish

Forming a team

Medium 1000 ms 128 MB 49%
Share

A class has $n$ boys and $m$ girls. A team of exactly $k$ people must be formed from them, with at least $g$ girls in it. The order of the team members does not matter. How many ways are there? Print the answer modulo $10^{9} + 7$.

Boys and girls; one of the k-person teams with at least g girls is highlighted

Input

One line with four integers: $n$, $m$, $k$ and $g$.

Output

One integer — the number of ways modulo $10^{9} + 7$.

Note

$0 \le n, m \le 10^{6}$
$1 \le k \le \max(1, n + m)$
$0 \le g \le k$

Examples

Input #1
4 3 3 2
Output #1
13
Input #2
2 1 3 2
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.