Under construction

Still being built. Things may change

Subtrees

Time limit2sMemory limit1024 MB

Summary
Given a tree with n vertices, count the ways to choose k vertex-disjoint subtrees for each k from 1 to n, modulo 10^9.
Level

Medium6 of 10

Topics
Dynamic programming, Tree, Combinatorics
Solved
No attempts yet

Problem

A tree is a connected undirected graph without cycles. A subtree of a tree TT is a connected subgraph of TT.

The number of subtrees depends on the structure of the tree. For example, a path of nn vertices has n(n+1)/2n(n+1)/2 subtrees, and a star (one central vertex connected to the other n−1n-1 vertices) has 2n−1+n−12^{n-1}+n-1 subtrees.

Similarly, the number of ways to choose two vertex-disjoint subtrees, three vertex-disjoint subtrees, and so on also depends on the structure of the tree.

Regardless of the structure, there are 2n−12n-1 ways to choose n−1n-1 vertex-disjoint subtrees, and exactly one way to choose nn vertex-disjoint subtrees (just nn isolated vertices).

Given a tree with nn vertices, print for each kk from 1 to nn the number of ways to choose kk vertex-disjoint subtrees of the tree.

Input

The first line contains nn (2≤n≤1002 \le n \le 100). The next n−1n-1 lines describe the edges of the tree.

Output

Print nn integers: for each kk from 1 to nn, the number of ways to choose kk vertex-disjoint subtrees of the given tree. Print each number modulo 10910^9.

Examples2

  1. Example 1

    Input
    5
    1 2
    2 3
    3 4
    4 5
    
    Expected output
    15
    35
    28
    9
    1
    
  2. Example 2

    Input
    5
    1 2
    1 3
    1 4
    1 5
    
    Expected output
    20
    38
    28
    9
    1