#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,mod; 
ll base[1010];
ll C[410][410],A[410];
ll dp[410][410];
void init()
{
	int i,j;
	base[1]=A[1]=1;
	for(i=2;i<=1000;i++)
		base[i]=base[i-1]*2%mod;
	for(i=0;i<=n;i++)
    {
        C[i][0]=1;
        for(j=1;j<=i;j++)
        {
            C[i][j]=C[i-1][j]+C[i-1][j-1];
            C[i][j]%=mod;
        }
    }
}
int main()
{
	cin>>n>>mod;
	init();
	int i,j,k;
	for(i=1;i<=n;i++)
	{
		dp[i][i]+=base[i];
		dp[i][i]%=mod;
		for(j=0;j<=i;j++)
		{
			for(k=1;i+k+1<=n;k++)
			{
				dp[i+k+1][j+k]+=dp[i][j]*base[k]%mod*C[j+k][k]%mod;
				dp[i+k+1][j+k]%=mod;
			}
		}
	}
	ll ans=0;
	for(i=0;i<=n;i++)
		ans+=dp[n][i],ans%=mod;
	cout<<ans<<endl;
	return 0;
}
### Prompt

Generate a cpp solution to 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 <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,mod; 
ll base[1010];
ll C[410][410],A[410];
ll dp[410][410];
void init()
{
	int i,j;
	base[1]=A[1]=1;
	for(i=2;i<=1000;i++)
		base[i]=base[i-1]*2%mod;
	for(i=0;i<=n;i++)
    {
        C[i][0]=1;
        for(j=1;j<=i;j++)
        {
            C[i][j]=C[i-1][j]+C[i-1][j-1];
            C[i][j]%=mod;
        }
    }
}
int main()
{
	cin>>n>>mod;
	init();
	int i,j,k;
	for(i=1;i<=n;i++)
	{
		dp[i][i]+=base[i];
		dp[i][i]%=mod;
		for(j=0;j<=i;j++)
		{
			for(k=1;i+k+1<=n;k++)
			{
				dp[i+k+1][j+k]+=dp[i][j]*base[k]%mod*C[j+k][k]%mod;
				dp[i+k+1][j+k]%=mod;
			}
		}
	}
	ll ans=0;
	for(i=0;i<=n;i++)
		ans+=dp[n][i],ans%=mod;
	cout<<ans<<endl;
	return 0;
}
```