#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; int P[5050]; vector E[5050]; map,ll> dp[5050]; const ll mo=998244353; void dfs(int cur) { map,ll> F; F[{0,1}]=1; FORR(e,E[cur]) { dfs(e); map,ll> T; FORR2(a,b,F) { FORR2(a2,b2,dp[e]) { (T[{max(a.first,a2.first),a.second+a2.second}]+=b*b2)%=mo; } } swap(F,T); } FORR2(a,b,F) { int i; FOR(i,a.second+1) (dp[cur][{a.first+i,a.second-i}]+=b)%=mo; } } void solve() { int i,j,k,l,r,x,y; string s; cin>>N; for(i=1;i>P[i]; P[i]--; E[P[i]].push_back(i); } dfs(0); ll ret=0; FORR2(a,b,dp[0]) ret+=b; cout<