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
#include <iostream>
using namespace std;

int arr[13][4];

int main() {
   arr[1][0] = 1;
   arr[2][1] = 2;
   arr[3][1] = 4;
   arr[3][2] = 2;
   arr[4][1] = 8;
   arr[4][2] = 16;
   arr[5][1] = 16;
   arr[5][2] = 100;
   arr[5][3] = 4;
   arr[6][1] = 32;
   arr[6][2] = 616;
   arr[6][3] = 72;
   arr[7][1] = 64;
   arr[7][2] = 4024;
   arr[7][3] = 952;
   arr[8][1] = 128;
   arr[8][2] = 28512;
   arr[8][3] = 11680;
   arr[9][1] = 256;
   arr[9][2] = 219664;
   arr[9][3] = 142800;
   arr[9][4] = 160;
   arr[10][1] = 512;
   arr[10][2] = 1831712;
   arr[10][3] = 1788896;
   arr[10][4] = 7680;
   arr[11][1] = 1024;
   arr[11][2] = 16429152;
   arr[11][3] = 23252832;
   arr[11][4] = 233792;
   arr[12][1] = 2048;
   arr[12][2] = 157552000;
   arr[12][3] = 315549312;
   arr[12][4] = 5898240;

   int n, k, p;
   cin>>n>>k>>p;
   cout<<arr[n][k] % p<<endl;
}