F: Red-Black Soul Gem

problem

Homu-chan has the mysterious power to change the soul game to red or black, and to connect two different soul games with a magic thread. By using this power, Homu-chan can create a magic square by Sorujemu.

Homu-chan was wondering how many different magic squares there were when there were N numbered magic squares numbered from 1 to N, and the following conditions were met:

* You can only connect once between any of the two sources.
* All the colors of the game are either red or black.
* For any game, it is connected to at least one of the games whose color is different from its own.



At this time, the magic square can be regarded as a graph with the sorujemu as the apex and the magic thread as the side. Note that the graph does not have to be concatenated.

Homu-chan is not good at calculating, so let's create a fast program instead and calculate the number of different magic squares. However, the number is expected to be very large, so we will find the remainder after dividing by a prime number M.

Note that the magic squares G and H are different because the colors of G and H are different for a certain magic square v, or the pair u and v of a certain magic square is one of G and H. It means that it is connected only with.

Input format


N M

Constraint

* 2 \ leq N \ leq 2,000
* 10 ^ 8 \ leq M \ leq 10 ^ 9 + 7
* M is guaranteed to be prime



Output format

Divide the number of graphs that satisfy the condition by M and output the remainder as an integer on one line.

Input example 1


3 310779401

Output example 1


12

For example, the following magic squares meet the conditions.

Input example 2


7 566666561

Output example 2


98638848

For example, the following magic squares meet the conditions.

Input example 3


1010 1000000007

Output example 3


862232855

Note that we output the remainder after dividing by M.





Example

Input

3 310779401


Output

12
#include "bits/stdc++.h"
#include<stdio.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv = vector<vector<T>>;
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
const ll MOD = 1e9 + 7;

int N;
LL M;
LL fact[11451];
LL revf[11451];
LL pw2[11451];

LL mypow(LL base, LL exp) {
	if (exp == 0) return 1;
	LL res = mypow(base*base%M, exp / 2);
	if (exp % 2) res = res * base%M;
	return res;
}

LL Comb(LL n, LL k) {
	if (k < 0 || n < k) return 0;
	return fact[n] * revf[k] % M * revf[n - k] % M;
}

int main() {
	cin >> N >> M;

	pw2[0] = 1 % M;
	fact[0] = revf[0] = 1;
	reps(i, 1, N + 10) {
		pw2[i] = pw2[i - 1] * 2 % M;
		fact[i] = fact[i - 1] * i % M;
		revf[i] = revf[i - 1] * mypow(i, M - 2) % M;
	}

	LL ans = 0;
	reps(k, 1, N) {
		LL totsum = 0;
		reps(l,1, N - k+1) {
			LL tot = 0;
			LL v = mypow(pw2[l] - 1, k);
			int sg = N - k - l;
			if (sg % 2) {
				tot += M - v;
			}
			else {
				tot += v;
			}
	//		cout << tot << endl;
			tot = tot * Comb(N - k, l);
			tot %= M;
			totsum += tot;
		}
		totsum %= M;
		LL m = Comb(N, k);
		LL p = k * LL(k - 1) / 2;
		LL q = (N - k)*LL(N - k - 1) / 2;

		m = m * mypow(2, p) % M;
		m = m * mypow(2, q) % M;
		ans += m * totsum;
		ans %= M;
	}
	printf("%lld\n", ans);
}

