Under construction

Still being built. Things may change

Buying Stamps

Interview

Time limit1sMemory limit1024 MB

Summary
Count the ways to buy stamps worth exactly K won from N kinds of 1-won and M kinds of 2-won stamps, modulo a prime P.
Level

Easy3 of 10

Topics
Dynamic programming
Solved
No attempts yet

Problem

The post office sells stamps. There are NN kinds of stamps priced at 1 won and MM kinds priced at 2 won.

Write a program that counts the ways to buy stamps worth exactly KK won.

You may buy several stamps of the same kind. The post office has an unlimited number of each stamp. You must use exactly KK won.

Input

The first line contains NN, MM, KK, and PP. (0≤N,M≤10000 \le N, M \le 1000, 1≤K≤10001 \le K \le 1000, 3≤P≤1,000,0003 \le P \le 1{,}000{,}000, PP is prime.)

Output

Print the number of ways to buy stamps, modulo PP, on the first line.

Examples3

  1. Example 1

    Input
    0 10 2 47
    
    Expected output
    10
    
  2. Example 2

    Input
    2 2 4 47
    
    Expected output
    14
    
  3. Example 3

    Input
    5 5 10 47
    
    Expected output
    6