eolymp
bolt
Try our new interface for solving problems
Problems

Big task

Big task

This time, Doofenshmirtz conceived such a big dirty trick that Perry can't handle it alone. Therefore, he decided to call his special agents from O.B.K.A.

In the office of O.B.K.A. there are n offices that are connected with n - 1 corridors. From any office you can get through the corridors to any other. In other words, the office of O.B.K.A. is a tree, the vertices of which correspond to the offices, and the edges to the corridors. There is exactly one special agent in each office, in office number v there is a special agent with the skill cv. There are m different skills in total, numbered from 1 to m.

Perry wants to select a special agent squad such that for each of the m skills in this squad there will be at least one special agent with that skill. Also, if Perry takes the special agents from offices v and u into the squad, he will also definitely take into the squad all the special agents who sit in the offices located on the path between u and v.

Help Perry figure out the number of ways he can choose a squad for a mission. Since this number can be large, print the remainder after dividing this number by 998 244 353.

Input

The first line contains two integers n and m (1n104, 1m10) - the number of rooms and the number of different skills.

The next line contains n integers ci (1cim) - the skills of the special agents.

The next n - 1 lines contain two integers ai and bi (1ai, bin) - numbers of rooms connected by i-th corridor.

It is guaranteed that the office of O.B.K.A. represents a tree.

Output

Print a single integer - the number of ways to choose a squad of special agents modulo 998 244 353.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 3
1 2 3
1 2
2 3
Output example #1
1
Input example #2
4 2
1 2 2 2
1 2
1 3
1 4
Output example #2
7
Input example #3
6 3
1 2 3 1 2 3
1 2
2 3
2 4
4 5
4 6
Output example #3
14
Source 2020 Cycle of Internet Olympiads for schoolchildren, Third team contest, Advanced level, Novemver 7, Problem G