#include #include #include #include #include using namespace std; typedef long long ll; typedef long double ld; typedef pair ii; typedef vector vi; typedef vector vvi; typedef vector vii; #define x first #define y second #define pb push_back #define eb emplace_back #define rep(i,a,b) for(auto i=(a); i<(b); ++i) #define REP(i,n) rep(i,0,n) #define all(v) (v).begin(), (v).end() #define rs resize #define DBG(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl const ld PI = acos(-1.0); template using min_queue = priority_queue, greater>; template int sz(const T &x) { return (int) x.size(); // copy the ampersand(&)! } template ostream& operator<<(ostream &os, vector &v) { os << "\n["; for(T &x : v) os << x << ','; return os << "]\n"; } struct pairhash { public: template size_t operator()(const pair &p) const { size_t lhs = hash()(p.x); size_t rhs = hash()(p.y); return lhs ^ (rhs+0x9e3779b9+(lhs<<6)+(lhs>>2)); } }; const ll MOD = 1'000'000'007; vvi adj; vvi P; ll n; void dfs(ll i, ll p) { for (ll k = 0; k <= n; k++) { P[i][k] = k; } for (ll j : adj[i]) { if (j == p) continue; dfs(j, i); for (ll k = 0; k <= n; k++) { P[i][k] *= P[j][k]+1; P[i][k] %= MOD; } } } ll inv(ll n) { ll a = n, b = MOD, xx = 0, y = 0, yy = 1, x = 1; while (b) { x -= a/b*xx; swap(x, xx); y -= a/b*yy; swap(y, yy); a %= b; swap(a, b); } return x%MOD; } void run() { cin >> n; adj = vvi(n); P = vvi(n, vi(n+1, 0)); for (ll i = 1; i < n; i++) { ll p; cin >> p; adj[i].pb(p); adj[p].pb(i); } dfs(0, -1); //for (ll i = 0; i < n; i++) { // for (ll j = 0; j < n; j++) { // cout << P[i][j] << " "; // } // cout << endl; //} vi Q(n+1, 0); for (ll i = 0; i < n; i++) { for (ll k = 0; k <= n; k++) { Q[k] += P[i][k]; Q[k] %= MOD; } } vvi binom(n+1, vi(n+1, 0)); for (ll i = 0; i <= n; i++) { for (ll j = 0; j <= i; j++) { if (j == 0 || j == i) { binom[i][j] = 1; } else { binom[i][j] = binom[i-1][j] + binom[i-1][j-1]; binom[i][j] %= MOD; } } } vi fact(n+1, 1); for (ll i = 1; i <= n; i++) { fact[i] = fact[i-1]*i; fact[i] %= MOD; } vvi modpow(n+1, vi(n+1, 1)); for (ll i = 0; i <= n; i++) { for (ll j = 1; j <= n; j++) { modpow[i][j] = modpow[i][j-1]*i%MOD; } } vi R(n+1, 0); for (ll i = n; i >= 0; i--) { for (ll j = 0; j <= i; j++) { if ((i+j)%2 == 0) { R[i] += binom[i][j]*Q[j]; } else { R[i] -= binom[i][j]*Q[j]; } R[i] %= MOD; } R[i] *= inv(fact[i]); R[i] %= MOD; //cout << i << ":" << endl; for (ll j = 0; j <= n; j++) { Q[j] -= R[i]*modpow[j][i]%MOD; Q[j] %= MOD; //cout << (Q[j]+MOD)%MOD << " "; } //cout << endl; } for (ll i = 1; i <= n; i++) { cout << (R[i]%MOD + MOD)%MOD << endl; } } signed main() { // DON'T MIX "scanf" and "cin"! ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(20); run(); return 0; }