405225: GYM101848 I Chessboard
Memory Limit:512 MB
Time Limit:5 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
I. Chessboardtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output
Count how many ways there are to color a m × n chessboard with black and white, such that the black blocks are 4-connected, and the white blocks are also 4-connected.
InputThree space-separated integers n, m, p. (1 ≤ m ≤ 8, 1 ≤ n·m ≤ 104, 2 ≤ p ≤ 109, p is prime.)
OutputOutput the answer modulo p.
ExamplesInput2 2 998244353Output
14Input
4 3 998244353Output
294Input
3 3 998244353Output
108Note
Example 3 has the following 108 ways: