#include <bits/stdc++.h>
using namespace std;

void __print(int x) { cerr << x; }
void __print(int64_t x) { cerr << x; }
void __print(uint32_t x) { cerr << x; }
void __print(uint64_t x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) { cerr << '('; __print(x.first); cerr << ", "; __print(x.second); cerr << ')'; }
template<typename T>
void __print(const T &x) { int f = 0; cerr << '{'; for(auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if(sizeof...(v)) cerr << ", "; _print(v...); }

#define debug(x...) cerr << " > [" << #x << "] = ["; _print(x)

const int MaxM = 405;

int64_t dp_0[3][MaxM][MaxM]; /// [bez, po, przed][-2, -1, cur][cnt-1][k-1]
int64_t dp_1[3][MaxM][MaxM]; /// [bez, po, przed][-2, -1, cur][cnt-1][k-1]
int64_t dp_2[3][MaxM][MaxM]; /// [bez, po, przed][-2, -1, cur][cnt-1][k-1]

int64_t pref_0[3][MaxM][MaxM];
int64_t pref_1[3][MaxM][MaxM];
int64_t pref_2[3][MaxM][MaxM];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    int64_t M;
    cin >> n >> M;
    dp_0[0][1][1] = 1;

    dp_1[1][2][2] = 1;
    dp_2[1][2][1] = 1;

    auto sum_0 = [&](int i, int cnt, int l, int r) {
        if(i < 6) {
            int64_t sum = 0;
            for(int j = l; j <= r; j++) {
                sum = (sum + dp_0[i % 3][cnt][j]) % M;
            }
            return sum;
        }
        else return pref_0[i % 3][cnt][r+1] - pref_0[i % 3][cnt][l];
    };

    auto sum_1 = [&](int i, int cnt, int l, int r) {
        if(i < 6) {
            int64_t sum = 0;
            for(int j = l; j <= r; j++) {
                sum = (sum + dp_1[i % 3][cnt][j]) % M;
            }
            return sum;
        }
        else return pref_1[i % 3][cnt][r+1] - pref_1[i % 3][cnt][l];
    };

    auto sum_2 = [&](int i, int cnt, int l, int r) {
        if(i < 6) {
            int64_t sum = 0;
            for(int j = l; j <= r; j++) {
                sum = (sum + dp_2[i % 3][cnt][j]) % M;
            }
            return sum;
        }
        else return pref_2[i % 3][cnt][r+1] - pref_2[i % 3][cnt][l];
    };

    for(int i = 2; i < n; i++) {
        for(int j = 0; j < MaxM; j++) {
            for(int k = 0; k < MaxM; k++) {
                dp_0[i%3][j][k] = 0;
                dp_1[i%3][j][k] = 0;
                dp_2[i%3][j][k] = 0;
            }
        }
        for(int cnt = 2; cnt <= i+1; cnt++) {
            for(int k = 1; k <= cnt; k++) {
                dp_0[i % 3][cnt][k] = (
                    sum_0(i-2, cnt-1, 1, cnt-1) +
                    sum_1(i-2, cnt-1, 1, cnt-1) +
                    sum_2(i-2, cnt-1, 1, cnt-1)
                ) % M;
                if(k > 1) {
                    dp_1[i % 3][cnt][k] = (
                        sum_0(i-1, cnt-1, 1, k-1) +
                        sum_1(i-1, cnt-1, 1, k-1) +
                        sum_2(i-1, cnt-1, 1, k-1)
                    ) % M;
                }
                if(k < cnt) {
                    dp_2[i % 3][cnt][k] = (
                        sum_0(i-1, cnt-1, k, cnt-1) +
                        sum_2(i-1, cnt-1, k, cnt-1)
                    ) % M;
                }
            }
        }
        for(int cnt = 2; cnt <= i+1; cnt++) {
            pref_0[i % 3][cnt][0] = 0;
            pref_1[i % 3][cnt][0] = 0;
            pref_2[i % 3][cnt][0] = 0;
            for(int k = 0; k <= cnt; k++) {
                pref_0[i % 3][cnt][k+1] = (pref_0[i % 3][cnt][k] + dp_0[i%3][cnt][k]) % M;
                pref_1[i % 3][cnt][k+1] = (pref_1[i % 3][cnt][k] + dp_1[i%3][cnt][k]) % M;
                pref_2[i % 3][cnt][k+1] = (pref_2[i % 3][cnt][k] + dp_2[i%3][cnt][k]) % M;
            }
        }
    }
    int64_t res = 0;
    for(int j = 0; j < MaxM; j++) {
        for(int k = 0; k < MaxM; k++) {
            res = (res + dp_0[(n-1) % 3][j][k] + dp_1[(n-1) % 3][j][k] + dp_2[(n-1) % 3][j][k]) % M;
        }
    }
    cout << res;

    return 0;
}



### Prompt

Create a solution in cpp for the following problem:

There are n computers in a row, all originally off, and Phoenix wants to turn all of them on. He will manually turn on computers one at a time. At any point, if computer i-1 and computer i+1 are both on, computer i (2 ≤ i ≤ n-1) will turn on automatically if it is not already on. Note that Phoenix cannot manually turn on a computer that already turned on automatically.

If we only consider the sequence of computers that Phoenix turns on manually, how many ways can he turn on all the computers? Two sequences are distinct if either the set of computers turned on manually is distinct, or the order of computers turned on manually is distinct. Since this number may be large, please print it modulo M.

Input

The first line contains two integers n and M (3 ≤ n ≤ 400; 10^8 ≤ M ≤ 10^9) — the number of computers and the modulo. It is guaranteed that M is prime.

Output

Print one integer — the number of ways to turn on the computers modulo M.

Examples

Input


3 100000007


Output


6


Input


4 100000007


Output


20


Input


400 234567899


Output


20914007

Note

In the first example, these are the 6 orders in which Phoenix can turn on all computers: 

  * [1,3]. Turn on computer 1, then 3. Note that computer 2 turns on automatically after computer 3 is turned on manually, but we only consider the sequence of computers that are turned on manually. 
  * [3,1]. Turn on computer 3, then 1. 
  * [1,2,3]. Turn on computer 1, 2, then 3. 
  * [2,1,3] 
  * [2,3,1] 
  * [3,2,1] 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;

void __print(int x) { cerr << x; }
void __print(int64_t x) { cerr << x; }
void __print(uint32_t x) { cerr << x; }
void __print(uint64_t x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) { cerr << '('; __print(x.first); cerr << ", "; __print(x.second); cerr << ')'; }
template<typename T>
void __print(const T &x) { int f = 0; cerr << '{'; for(auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if(sizeof...(v)) cerr << ", "; _print(v...); }

#define debug(x...) cerr << " > [" << #x << "] = ["; _print(x)

const int MaxM = 405;

int64_t dp_0[3][MaxM][MaxM]; /// [bez, po, przed][-2, -1, cur][cnt-1][k-1]
int64_t dp_1[3][MaxM][MaxM]; /// [bez, po, przed][-2, -1, cur][cnt-1][k-1]
int64_t dp_2[3][MaxM][MaxM]; /// [bez, po, przed][-2, -1, cur][cnt-1][k-1]

int64_t pref_0[3][MaxM][MaxM];
int64_t pref_1[3][MaxM][MaxM];
int64_t pref_2[3][MaxM][MaxM];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    int64_t M;
    cin >> n >> M;
    dp_0[0][1][1] = 1;

    dp_1[1][2][2] = 1;
    dp_2[1][2][1] = 1;

    auto sum_0 = [&](int i, int cnt, int l, int r) {
        if(i < 6) {
            int64_t sum = 0;
            for(int j = l; j <= r; j++) {
                sum = (sum + dp_0[i % 3][cnt][j]) % M;
            }
            return sum;
        }
        else return pref_0[i % 3][cnt][r+1] - pref_0[i % 3][cnt][l];
    };

    auto sum_1 = [&](int i, int cnt, int l, int r) {
        if(i < 6) {
            int64_t sum = 0;
            for(int j = l; j <= r; j++) {
                sum = (sum + dp_1[i % 3][cnt][j]) % M;
            }
            return sum;
        }
        else return pref_1[i % 3][cnt][r+1] - pref_1[i % 3][cnt][l];
    };

    auto sum_2 = [&](int i, int cnt, int l, int r) {
        if(i < 6) {
            int64_t sum = 0;
            for(int j = l; j <= r; j++) {
                sum = (sum + dp_2[i % 3][cnt][j]) % M;
            }
            return sum;
        }
        else return pref_2[i % 3][cnt][r+1] - pref_2[i % 3][cnt][l];
    };

    for(int i = 2; i < n; i++) {
        for(int j = 0; j < MaxM; j++) {
            for(int k = 0; k < MaxM; k++) {
                dp_0[i%3][j][k] = 0;
                dp_1[i%3][j][k] = 0;
                dp_2[i%3][j][k] = 0;
            }
        }
        for(int cnt = 2; cnt <= i+1; cnt++) {
            for(int k = 1; k <= cnt; k++) {
                dp_0[i % 3][cnt][k] = (
                    sum_0(i-2, cnt-1, 1, cnt-1) +
                    sum_1(i-2, cnt-1, 1, cnt-1) +
                    sum_2(i-2, cnt-1, 1, cnt-1)
                ) % M;
                if(k > 1) {
                    dp_1[i % 3][cnt][k] = (
                        sum_0(i-1, cnt-1, 1, k-1) +
                        sum_1(i-1, cnt-1, 1, k-1) +
                        sum_2(i-1, cnt-1, 1, k-1)
                    ) % M;
                }
                if(k < cnt) {
                    dp_2[i % 3][cnt][k] = (
                        sum_0(i-1, cnt-1, k, cnt-1) +
                        sum_2(i-1, cnt-1, k, cnt-1)
                    ) % M;
                }
            }
        }
        for(int cnt = 2; cnt <= i+1; cnt++) {
            pref_0[i % 3][cnt][0] = 0;
            pref_1[i % 3][cnt][0] = 0;
            pref_2[i % 3][cnt][0] = 0;
            for(int k = 0; k <= cnt; k++) {
                pref_0[i % 3][cnt][k+1] = (pref_0[i % 3][cnt][k] + dp_0[i%3][cnt][k]) % M;
                pref_1[i % 3][cnt][k+1] = (pref_1[i % 3][cnt][k] + dp_1[i%3][cnt][k]) % M;
                pref_2[i % 3][cnt][k+1] = (pref_2[i % 3][cnt][k] + dp_2[i%3][cnt][k]) % M;
            }
        }
    }
    int64_t res = 0;
    for(int j = 0; j < MaxM; j++) {
        for(int k = 0; k < MaxM; k++) {
            res = (res + dp_0[(n-1) % 3][j][k] + dp_1[(n-1) % 3][j][k] + dp_2[(n-1) % 3][j][k]) % M;
        }
    }
    cout << res;

    return 0;
}



```