Under construction

Still being built. Things may change

Simple Tree Decomposition Problem

Interview

Time limit3sMemory limit1024 MB

Summary
Count the edge subsets of a tree whose removal leaves every connected component with exactly A or B vertices, modulo 10^9+7.
Level

Medium6 of 10

Topics
Tree, Dynamic programming
Solved
No attempts yet

Problem

BOOM! Dohoon's head exploded while he was solving the tree decomposition practice problem assigned at the Summer School on Combinatorics and Algorithms at KAIST. His brain could no longer focus on the problem, so it started idling by decomposing a tree instead of doing tree decomposition on general graphs.

Dohoon is given a tree with NN vertices. He decomposes the tree into a collection of connected components as follows.

  1. He selects zero or more edges from the tree and removes them. Let SS be the set of removed edges.
  2. After the edges in SS are removed, each connected component must have either AA or BB vertices.

Count the number of possible sets of edges SS that satisfy these conditions.

Input

The first line contains three integers NN, AA, BB, separated by spaces. Each of the following N−1N-1 lines contains two integers xix_i and yiy_i, separated by a space, meaning that the ii-th edge connects vertices xix_i and yiy_i.

Output

Print the number of possible sets SS modulo 109+710^9+7.

Constraints

1≤N≤100 0001 \le N \le 100\,000

1≤A<B≤5001 \le A < B \le 500

1≤xi<yi≤N1 \le x_i < y_i \le N (1≤i≤N−11 \le i \le N-1)

The given edges form a tree.

Examples1

  1. Example 1

    Input
    6 1 2
    1 2
    2 3
    2 4
    4 5
    4 6
    
    Expected output
    10