Number of connected components

You are given a tree, that is, an undirected, connected graph with no cycles. Can you count how many (non-empty) connected subgraphs it contains?

Input

Input consists of several trees, each one with the number of vertices nn, followed by its n1n - 1 edges. You can assume 1n1051 \le n \le 10^5, that vertices are numbered between 0 and n1n - 1, and that the given edges indeed form a tree.

Output

For every given tree, print its number of connected subgraphs. As this number may be large, make the computations modulo 108+710^8 + 7.

Problem information

Author: Edgar Moreno

Generation: 2026-01-25T11:52:55.342Z

© Jutge.org, 2006–2026.
https://jutge.org