Under construction

Still being built. Things may change

Connected Subgraph

Time limit1sMemory limit256 MB

Summary
Count the ways to delete some edges from a tree plus k extra edges so the remaining graph stays connected, modulo 998244353.
Level

Hard9 of 10

Topics
Tree, Dynamic programming, Bit manipulation
Solved
No attempts yet

Problem

Rikka draws a tree with nn vertices labeled 1,2,…,n1, 2, \ldots, n and adds kk extra edges to it. Count the ways she can remove zero or more edges so that the remaining graph stays connected, modulo 998 244 353998\,244\,353.

Input

The first line contains two integers nn and kk (1≤n≤1051 \le n \le 10^5, 0≤k≤100 \le k \le 10). Each of the next n−1n-1 lines contains two integers aia_i and bib_i, a tree edge between vertices aia_i and bib_i (1≤ai,bi≤n1 \le a_i, b_i \le n). Each of the last kk lines contains two integers uiu_i and viv_i, an extra edge between vertices uiu_i and viv_i (1≤ui,vi≤n1 \le u_i, v_i \le n). The tree edges form a tree. The resulting graph has no self-loops and no parallel edges.

Output

Print one integer: the number of ways to remove zero or more edges so that the graph remains connected, modulo 998 244 353998\,244\,353.

Examples2

  1. Example 1

    Input
    5 1
    1 2
    2 3
    3 4
    4 5
    1 5
    
    Expected output
    6
    
  2. Example 2

    Input
    4 2
    1 2
    2 3
    2 4
    3 4
    1 4
    
    Expected output
    14