structNode { int a[K]; Node() : a{} {} int& operator [](int x) { return a[x]; } Node& operator +=(Node t) { for (int i = 0; i <= k; ++ i) adj(a[i] += t[i] - Mod); return *this; } Node& operator -() { for (int i = 0; i <= k; ++ i) adj(a[i] = -a[i]); return *this; } Node operator +(Node t) const { return t += *this; } Node operator -(Node t) const { return *this + -t; } Node nxt(){ Node res = *this; for (int i = 1; i <= k; ++ i) adj(res[i] += a[i - 1] - Mod); return res; } } f1[N], f2[N];
voiddfs1(int x, int fa = 0) { f1[x][0] = 1; for (int v : g[x]) if (v ^ fa) dfs1(v, x), f1[x] += f1[v].nxt(); }
voiddfs2(int x, int fa = 0) { if (fa) f2[x] = (f1[fa] - f1[x].nxt() + f2[fa]).nxt(); for (int v : g[x]) if (v ^ fa) dfs2(v, x); }
intmain() { init(); std::cin >> n >> k; for (int i = 1, u, v; i < n; ++ i) { scanf("%d %d", &u, &v); g[u].push_back(v), g[v].push_back(u); } dfs1(1), dfs2(1); for (int i = 1; i <= n; ++ i) { Node sta = f1[i] + f2[i]; int res = 0; for (int i = 0; i <= k; ++ i) res = (res + (LL) S[k][i] * sta[i] % Mod * fact[i]) % Mod; printf("%d\n", res); } return0; }