QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 512 MB Points totaux : 100 Difficulté: [afficher]

#2304. Line Graph

Statistiques

Kelian Jiutian is a girl who loves creating problems.

Today, Kelian wants to create a problem related to graph theory. On an undirected graph $G$, we can perform some very interesting transformations, such as taking the dual or the complement. Such operations often breathe new life into traditional problems. For example, finding the connectivity of a complement graph or the shortest path in a complement graph are very interesting problems.

Recently, Kelian learned about a new transformation: finding the line graph of the original graph. For an undirected graph $G = \langle V, E \rangle$, its line graph $L(G)$ is also an undirected graph: Its vertex set size is $|E|$, and each vertex corresponds uniquely to an edge in the original graph. There is an edge between two vertices if and only if the corresponding edges in the original graph share a common vertex (note that there are no self-loops).

The figure below shows a simple example. The left graph is the original graph, and the right graph is its corresponding line graph. Here, vertex 1 corresponds to edge $(1, 2)$ in the original graph, vertex 2 corresponds to $(1, 4)$, vertex 3 corresponds to $(1, 3)$, and vertex 4 corresponds to $(3, 4)$.

After some initial exploration, Kelian discovered that the properties of line graphs are much more complex than those of complement graphs. A prominent point is that the complement of a complement graph returns to the original graph, while $L(L(G))$ is not equal to $G$ in most cases, and in many cases, its number of vertices and edges grows at a very fast rate.

Therefore, Kelian wants to start with the simplest case, which is calculating the number of vertices in $L^k(G)$ (where $L^k(G)$ denotes applying the line graph transformation to $G$ for $k$ times).

Unfortunately, even this problem is too difficult for Kelian, so she simplified it. She provides a tree $T$ with $n$ nodes, and now she wants you to calculate the number of vertices in $L^k(T)$.

Input

The first line contains two integers $n$ and $k$, representing the number of nodes in the tree and the number of times the line graph transformation is applied.

The next $n - 1$ lines each contain two integers $u, v$, representing an edge in the tree.

Output

Output a single integer representing the answer modulo 998244353.

Examples

Input 1

5 3
1 2
2 3
2 5
3 4

Output 1

5

Note 1

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

Constraints

Test Case $k$ Test Case $k$
1 $= 2$ 6 $= 6$
2 $= 3$ 7 $= 7$
3 $= 4$ 8 $= 8$
4 $= 5$ 9 $= 9$
5 $= 5$ 10 $= 9$

For 100% of the data, $2 \le n \le 5000$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.