luogu#P4895. 独钓寒江雪

独钓寒江雪

Problem Description

Given an unrooted tree, find the number of essentially different independent sets in it.

Input Format

The first line contains an integer nn, the number of nodes in the tree (n5×105n \leq 5\times 10^5).

Lines 22 to nn each contain two integers uu and vv, indicating that there is an edge connecting uu and vv.

Output Format

Output a single integer: the number of valid ways modulo 109+710^9+7.

1

2
5
1 2
1 3
1 4
1 5
6
6
1 2
1 3
1 4
4 5
4 6
9

Hint

Translated by ChatGPT 5