atcoder#ARC108F. [ARC108F] Paint Tree

[ARC108F] Paint Tree

Score : 900900 points

Problem Statement

Given is a tree with NN vertices numbered 11 to NN, and N1N-1 edges numbered 11 to N1N-1. Edge ii connects Vertex aia_i and bib_i bidirectionally and has a length of 11.

Snuke will paint each vertex white or black. The niceness of a way of painting the graph is max(X,Y)\max(X, Y), where XX is the maximum among the distances between white vertices, and YY is the maximum among the distances between black vertices. Here, if there is no vertex of one color, we consider the maximum among the distances between vertices of that color to be 00.

There are 2N2^N ways of painting the graph. Compute the sum of the nicenesses of all those ways, modulo (109+7)(10^{9}+7).

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^{5}
  • 1ai,biN1 \leq a_i, b_i \leq N
  • The given graph is a tree.

Input

Input is given from Standard Input in the following format:

NN

a1a_1 b1b_1

\vdots

aN1a_{N-1} bN1b_{N-1}

Output

Print the sum of the nicenesses of the ways of painting the graph, modulo (109+7)(10^{9}+7).

2
1 2
2
  • If we paint Vertex 11 and 22 the same color, the niceness will be 11; if we paint them different colors, the niceness will be 00.
  • The sum of those nicenesses is 22.
6
1 2
2 3
3 4
4 5
3 6
224
35
25 4
33 7
11 26
32 4
12 7
31 27
19 6
10 22
17 12
28 24
28 1
24 15
30 24
24 11
23 18
14 15
4 29
33 24
15 34
11 3
4 35
5 34
34 2
16 19
7 18
19 31
22 8
13 26
20 6
20 9
4 33
4 8
29 19
15 21
298219707
  • Be sure to compute the sum modulo (109+7)(10^{9}+7).