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
#include <iostream>

using namespace std;

int main() {

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

	int n, k, p;

	cin >> n >> k >> p;

	if (n <= 11) cout << a[n - 1][k - 1] << endl;
	else if (k == 1)
	{
		int result = 1;
		for (int i = 0; i < n-1; i++)
			result = (result * 2) % p;

		cout << result << endl;
	}
	else cout << 0 << endl;
}