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

using namespace std;

int main(){
    long long num, val, mod;
    cin>>num>>val>>mod;
    vector <vector <long long> > hard_code={
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 16, 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 32, 616, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 64, 4024, 952, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 128, 28512, 11680, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 256, 219664, 142800, 160, 0, 0, 0, 0, 0, 0, 0, 0}, 
    {0, 512, 1831712, 1788896, 7680, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 1024, 16429152, 23252832, 233792, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 2048, 157552000, 315549312, 5898240, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 4096, 1606874944, 4483860928, 136280832, 0, 0, 0, 0, 0, 0, 0, 0} };
    long long res = hard_code[num][val];
    res %= mod;
    cout<<res<<endl;
}