1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>

int tab[12][4] =
{
	{0, 0, 0, 0},
	{2, 0, 0, 0},
	{4, 2, 0, 0},
	{8, 16, 0, 0},
	{16, 100, 4, 0},
	{32, 616, 72, 0},
	{64, 4024, 952, 0},
	{128, 28512, 11680, 0},
	{256, 219664, 142800, 160},
	{512, 1831712, 1788896, 7680},
	{1024, 16429152, 23252832, 233792},
	{2048, 157552000, 315549312, 5898240}
};

int main()
{
	int n,k,p;
	std::cin>>n>>k>>p;
	int res=0;
	if(k==1)
	{
		res=1;
		while(--n)
			res=(res*2)%p;
	}
	else if(k<=4)
		res=tab[n-1][k-1]%p;
	else
		res=0;
	std::cout<<res;
	return 0;
}