Under construction

Still being built. Things may change

Match

Time limit1sMemory limit512 MB

Summary
Given a tree with n nodes, count the edge subsets whose remaining forest has a maximum matching size divisible by m, modulo 998244353.
Level

Hard8 of 10

Topics
Tree, Dynamic programming, DFS, Math
Solved
No attempts yet

Problem

Yuta has a connected undirected graph G=⟨V,E⟩G = \langle V, E \rangle with nn nodes and n−1n - 1 edges. Yuta can choose some subset of the edges in EE and remove them. There are 2n−12^{n - 1} possible subsets to remove.

Yuta wants to count the ways to remove edges so that the maximum matching size of the remaining graph G′G' is divisible by mm. The answer can be very large, so print it modulo 998 244 353998\,244\,353.

An edge set SS is a matching if each node in VV is connected to at most one edge in SS. The maximum matching of GG is the matching of GG with the largest size.

Input

The first line contains two integers nn and mm (1≤n≤5⋅1041 \leq n \leq 5 \cdot 10^4, 1≤m≤2001 \leq m \leq 200). Then n−1n - 1 lines follow, each containing two integers uu and vv that describe an edge of GG.

Output

Print a single integer: the answer modulo 998 244 353998\,244\,353.

Examples1

  1. Example 1

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