#include using namespace std; typedef long long ll; template ostream& operator << (ostream& os, const pair v){ os << "(" << v.first << ", " << v.second << ")"; return os; } template ostream& operator << (ostream& os, const vector v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template ostream& operator << (ostream& os, const vector> v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } #define WHATS(var) //cout<<#var<<"="<(n)) { ; } operator int() { return num; } }; Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); } Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; } Mod operator+(const Mod a, const long long int b) { return b + a; } Mod operator++(Mod &a) { return a + Mod(1); } Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); } Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; } Mod operator--(Mod &a) { return a - Mod(1); } Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); } Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; } Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; } Mod operator*(const Mod a, const int b) { return Mod(b)*a; } Mod operator+=(Mod &a, const Mod b) { return a = a + b; } Mod operator+=(long long int &a, const Mod b) { return a = a + b; } Mod operator-=(Mod &a, const Mod b) { return a = a - b; } Mod operator-=(long long int &a, const Mod b) { return a = a - b; } Mod operator*=(Mod &a, const Mod b) { return a = a * b; } Mod operator*=(long long int &a, const Mod b) { return a = a * b; } Mod operator*=(Mod& a, const long long int &b) { return a = a * b; } Mod operator^(const Mod a, const int n) { if (n == 0) return Mod(1); Mod res = (a * a) ^ (n / 2); if (n % 2) res = res * a; return res; } Mod mod_pow(const Mod a, const int n) { if (n == 0) return Mod(1); Mod res = mod_pow((a * a), (n / 2)); if (n % 2) res = res * a; return res; } Mod inv(const Mod a) { return a ^ (mod - 2); } Mod operator/(const Mod a, const Mod b) { assert(b.num != 0); return a * inv(b); } Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; } Mod operator/=(Mod &a, const Mod b) { return a = a / b; } #define MAX_MOD_N 102400 Mod fact[MAX_MOD_N], factinv[MAX_MOD_N]; void init(const int amax = MAX_MOD_N) { fact[0] = Mod(1); factinv[0] = 1; for (int i = 0; i < amax - 1; ++i) { fact[i + 1] = fact[i] * Mod(i + 1); factinv[i + 1] = factinv[i] / Mod(i + 1); } } Mod comb(const int a, const int b) { return fact[a] * factinv[b] * factinv[a - b]; } int MAX_N=556; vector>>dp(2,vector>(MAX_N+1,vector(2*MAX_N+1))); int main() { ios::sync_with_stdio(false); init(); int X;cin>>X; dp[0][0][0]=1; for(int i=1;i<=X;++i){ int cur=i&1; int tar=1-cur; for(int ok=0;ok<=i;++ok){ for(int ng=0;ng<=2*i;++ng){ ll sum=0; sum+=dp[tar][ok][ng]*ok; if(ok)sum+=dp[tar][ok-1][ng+1]*(ng+1); if(ok)sum+=dp[tar][ok-1][ng]; //ok ok sum+=dp[tar][ok][ng]*ok*(ok-1); //ok ng sum+=dp[tar][ok][ng]*ok*ng*2; //ok emp if(ng)sum+=dp[tar][ok][ng-1]*ok*2; //ng ng sum+=dp[tar][ok][ng]*ng*(ng-1); // ng emp if(ng)sum+=dp[tar][ok][ng-1]*(ng-1)*2; //emp emp if(ng>=2)sum+=dp[tar][ok][ng-2]; dp[cur][ok][ng]=sum%mod; WHATS(cur); WHATS(ok) WHATS(ng) WHATS(dp[cur][ok][ng]); } } dp[tar]=vector>(MAX_N+1,vector(2*MAX_N+1)); } ll answer=0; WHATS(answer) for(int ok=1;ok<=MAX_N;++ok){ answer+=dp[(X&1)][ok][0]%mod; } cout<