#include using namespace std; using ll = long long; const int inf = 1 << 30; const ll INF = 1LL << 60; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; #define rep(i, s, t) for (ll i = (ll)s; i < (ll)(t); i++) #define rrep(i, s, t) for (ll i = (ll)(t) - 1; i >= (ll)(s); i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmin(T1& x, T2 y) { return x > y ? (x = y, true) : false; } template bool chmax(T1& x, T2 y) { return x < y ? (x = y, true) : false; } template using min_heap = priority_queue, greater>; template using max_heap = priority_queue; #include using mint = atcoder::modint998244353; void solve() { int N; cin >> N; vector> G(N); vector P(N, -1); rep(i, 1, N) { int p; cin >> p; p--; P[i] = p; G[i].push_back(p); G[p].push_back(i); } vector> dp(N); vector D(N); auto dfs = [&](auto dfs, int x, int p) -> void { D[x] = 1; dp[x].resize(D[x] + 1); dp[x][1] = 1; for (auto i : G[x]) { if (i == p) continue; dfs(dfs, i, x); vector nxt(D[x] + D[i] + 1); rep(k, 0, D[x] + 1) rep(l, 0, D[i] + 1) { nxt[k] += dp[x][k] * dp[i][l]; if (k + l + 1 <= D[x] + D[i]) nxt[k + l + 1] -= dp[x][k] * dp[i][l]; } rep(k, 0, D[x] + D[i]) nxt[k + 1] += nxt[k]; D[x] += D[i]; swap(dp[x], nxt); } }; dfs(dfs, 0, -1); mint ans = 0; rep(i, 0, N + 1) ans += (i + 1) * dp[0][i]; cout << ans.val() << "\n"; } int main() { cin.tie(0)->sync_with_stdio(0); cout << fixed << setprecision(15); srand(time(NULL)); int T; // cin >> T; T = 1; while (T--) solve(); }