#P4337. [ZJOI2018] 线图

    ID: 3267 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2018各省省选浙江枚举,暴力剪枝状态压缩,状压

[ZJOI2018] 线图

Description

Today, Kelian wants to make a problem related to graph theory. On an undirected graph GG, we can perform some interesting transformations, such as taking the dual or the complement. These operations often bring new life to classical problems. For example, connectivity of the complement graph and shortest paths on the complement graph are both very interesting problems.

Recently, Kelian learned a new transformation: taking the line graph of the original graph. For an undirected graph G=V,EG = ⟨V, E⟩, its line graph L(G)L(G) is also an undirected graph:

  • Its vertex set has size E|E|, and each vertex corresponds uniquely to an edge of the original graph.
  • There is an edge between two vertices if and only if the two corresponding edges in the original graph share an endpoint (note that there are no self-loops). The figure below shows a simple example: the left figure is the original graph, and the right figure is its line graph. Vertex 11 corresponds to edge (1,2)(1, 2) in the original graph, vertex 22 corresponds to (1,4)(1, 4), vertex 33 corresponds to (1,3)(1, 3), and vertex 44 corresponds to (3,4)(3, 4).

After some initial exploration, Kelian found that the properties of line graphs are much more complicated than those of complement graphs. A notable point is that the complement of the complement returns to the original graph, while L(L(G))L(L(G)) is not equal to GG in most cases, and in many cases the number of vertices and edges grows rapidly.

Therefore, Kelian wants to start from the simplest case, namely computing the number of vertices of Lk(G)L^k(G) (where Lk(G)L^k(G) means taking the line graph of GG kk times). Unfortunately, even this problem is too hard for her, so she weakens it. She gives a tree TT with nn nodes and asks you to compute the number of vertices in Lk(T)L^k(T).

Input Format

The first line contains two integers n,kn, k, denoting the number of vertices in the tree and the number of times to take the line graph.

The next n1n - 1 lines each contain two integers u,vu, v, representing an edge of the tree.

Output Format

Output a single integer: the answer modulo 998244353998244353.

5 3 
1 2 
2 3 
2 5
3 4
5

Hint

As shown below, the left figure is the original tree, the middle figure is L(G)L(G), and the right figure is L2(G)L^2(G). L3(G)L^3(G) is not shown here, but since L2(G)L^2(G) has 5 edges, L3(G)L^3(G) has 5 vertices.

Translated by ChatGPT 5