403363: GYM101138 K The World of Trains

Memory Limit:512 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. The World of Trainstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

In the computer world, a train of the length n can be represented as an array A of the same length. Such an array A contains integer elements between 1 and k, inclusive. Each element in A represents the quality of one carriage. You can notice that there are exactly kn distinct trains.

Mike loves to travel and today he is going to do it with his friends. They want to occupy exactly d consecutive carriages. Of course, they want chosen d carriages to be of equal quality.

Someone saw a train and thus knows an array A. He said that there are exactly t ways for them to choose d consecutive carriages of equal quality. Now, Mike wants to know how many trains satisfy this description. Your task is to count them modulo 109 + 7.

Input

The only line of the input contains four integers n, d, t and k (1 ≤ d ≤ n ≤ 3333, 0 ≤ t ≤ n - d + 1, 1 ≤ k ≤ 109).

Output

Find the number of distinct trains fitting the given description, and print it modulo 109 + 7.

ExamplesInput
5 2 1 2
Output
8
Input
3 2 2 5
Output
5
Input
3 2 0 5
Output
80
Note

For the first sample test the only possible arrays are:

  1. {1, 1, 2, 1, 2}
  2. {1, 2, 1, 1, 2}
  3. {1, 2, 1, 2, 2}
  4. {1, 2, 2, 1, 2}
  5. {2, 1, 1, 2, 1}
  6. {2, 1, 2, 1, 1}
  7. {2, 1, 2, 2, 1}
  8. {2, 2, 1, 2, 1}

加入题单

算法标签: