QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#13244. Yubari's Modification

统计

The Admirals were surprised to find that very few retrofits were implemented in 2019.

Investigations revealed that the head of the retrofit factory, Yuuri, had withheld blueprints intended for other ship girls. In the first month of 2020, she used these blueprints to perform magnificent retrofits, resulting in three forms: Yuuri Kai Ni, Yuuri Kai Ni Toku, and Yuuri Kai Ni Tei. With capabilities for anti-air, anti-ground, anti-submarine, opening torpedo strikes, and five equipment slots, she became capable of anything. The naval base's 80,000 steel reserves were tragically depleted.

A ship girl's structure can be viewed as a tree with $n$ nodes, labeled $0 \sim n-1$. Using one blueprint, one can remove an edge from the tree and add a new edge such that the resulting structure remains a tree.

Now, Yuuri wants to continue taking other ship girls' blueprints in 2020 to retrofit herself, and she has taken a total of $k$ blueprints. She wants to know how many different forms she can have after these retrofits. Two forms are considered different if there exists an edge $(x, y)$ that appears in one tree but not in the other.

Input

The first line contains two integers $n$ and $k$, representing the number of nodes in the tree and the number of blueprints, respectively.

The second line contains $n-1$ integers $f_i$, describing the structure of the tree, where the parent of node $i$ is $f_i$.

Output

Output a single integer representing the answer, modulo $998244353$.

Examples

Input 1

3 1
0 0

Output 1

3

Input 2

4 1
0 1 2

Output 2

8

Input 3

6 1
0 1 2 2 0

Output 3

28

Note

For all data, $1 \le n \le 50$ and $0 \le k \le n$.

For 20% of the data, $k = 0$. (Test case 1 has $k = 0$).

For 20% of the data (test cases 1–4), $f_i = 0$.

For 30% of the data (test cases 1–6), $n \le 5$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.