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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//Autor: Mateusz Wasylkiewicz
//Zawody: Potyczki Algorytmiczne 2018
//Strona: http://potyczki.mimuw.edu.pl/
//Zadanie: Skwarki, runda 5B
//Czas: Theta(1)
//Cechy: heureza
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

const LL T[14][5] = {
		{0LL,0LL,0LL,0LL,0LL},
		{1LL,0LL,0LL,0LL,0LL},
		{0LL,2LL,0LL,0LL,0LL},
		{0LL,4LL,2LL,0LL,0LL},
		{0LL,8LL,16LL,0LL,0LL},
		{0LL,16LL,100LL,4LL,0LL},
		{0LL,32LL,616LL,72LL,0LL},
		{0LL,64LL,4024LL,952LL,0LL},
		{0LL,128LL,28512LL,11680LL,0LL},
		{0LL,256LL,219664LL,142800LL,160LL},
		{0LL,512LL,1831712LL,1788896LL,7680},
		{0LL,1024LL,16429152LL,23252832LL,233792LL},
		{0LL,2048LL,157552000LL,315549312LL,5898240LL},
		{0LL,4096LL,1606874944LL,4483860928LL,136280832LL}};
LL N, K, P;

void wczytaj_dane()
{
	cin >> N >> K >> P;
}

LL rozwiaz()
{
	if (N >= 14 || K >= 5)
		return 0;
	return T[N][K];
}

void zrob_test()
{
	wczytaj_dane();
	cout << (rozwiaz() % P) << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	zrob_test();
	return 0;
}