#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; #include using namespace atcoder; using mint = modint998244353; ostream &operator<<(ostream &os, const mint &p) { return os << p.val(); } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; V p(N); rep(i, N - 1) { cin >> p[i + 1]; p[i + 1]--; } V> G(N); for (int i = 1; i < N; i++) { G[i].push_back(p[i]); G[p[i]].push_back(i); } V d(N, 0); V> dp(N, V(2, 1)); auto rec = [&](auto f, int cur, int par) -> void { for (auto &nx : G[cur]) { if (nx == par) continue; d[nx] = d[cur] + 1; f(f, nx, cur); } }; rec(rec, 0, -1); mint ans = 1; for (int i = 1; i < N; i++) ans *= d[i]; cout << ans << '\n'; return 0; }