Buying Stamps

Count the ways to spend exactly K won using N kinds of 1-won stamps and M kinds of 2-won stamps, allowing repeats, modulo prime P.

Hard8CombinatoricsDynamic programmingMathNumber theoryNo attempts yetTime limit2sMemory limit512 MB

Problem

A post office sells NN kinds of stamps that cost 1 won each and MM kinds that cost 2 won each. Stamps of different kinds count as different stamps.

Write a program that counts the ways to buy exactly KK won worth of stamps and prints that count modulo PP.

You may buy several copies of the same kind, and the post office has an unlimited supply. The order of purchase does not matter, so two ways are the same when they take the same number of stamps of every kind. The whole KK won must be spent exactly, with nothing left over.

Input

The first line contains NN, MM, KK, and PP, separated by spaces. (0N,M3000 \le N, M \le 300, 1K10121 \le K \le 10^{12}, 3P1,000,0003 \le P \le 1{,}000{,}000, and PP is prime.)

Output

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