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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>


using namespace std;

long np[100][100];

int main() {

np[1][0] = 1;
np[1][1] = 0;
//n=2
np[2][1] = 2;
//n=3
np[3][1] = 4;
np[3][2] = 2;
//n=4
np[4][1] = 8;
np[4][2] = 16;
//n=5
np[5][1] = 16;
np[5][2] = 100;
np[5][3] = 4;
//n=6
np[6][1] = 32;
np[6][2] = 616;
np[6][3] = 72;
//n=7
np[7][1] = 64;
np[7][2] = 4024;
np[7][3] = 952;
//n=8
np[8][1] = 128;
np[8][2] = 28512;
np[8][3] = 11680;
//n=9
np[9][1] = 256;
np[9][2] = 219664;
np[9][3] = 142800;
np[9][4] = 160;
//n=10
np[10][1] = 512;
np[10][2] = 1831712;
np[10][3] = 1788896;
np[10][4] = 7680;
//n=11
np[11][1] = 1024;
np[11][2] = 16429152;
np[11][3] = 23252832;
np[11][4] = 233792;
//n=12
np[12][1] = 2048;
np[12][2] = 157552000;
np[12][3] = 315549312;
np[12][4] = 5898240;
//n=13
np[13][1] = 4096;
np[13][2] = 1606874944;
np[13][3] = 188893632;
np[13][4] = 136280832;
//n=14
np[14][1] = 8192;
np[14][2] = 17350247552;
np[14][3] = 66800134784;
np[14][4] = 3027900672;


    int N, K, P;
    cin>>N>>K>>P;
    if (N>1 and K==1) {
        long v=1;
        for(; N>1; --N) v*=2;
        cout<<(v%P)<<endl;
    } else if (N>14 or K>4) {
        cout<<0<<endl;
    } else {
        cout<<(np[N][K]%P)<<endl;
    }
    

    return 0;
}