Given a tree with $$$n$$$ nodes, each node has a color black or white, and also given $$$q$$$ queries:
Let's call a subset of nodes $$$S$$$ connected if for any two nodes $$$(v, u)$$$ from $$$S$$$, all nodes on the path between $$$v$$$ and $$$u$$$ are also in $$$S$$$.
Let's call a subset of nodes $$$S$$$ monochromatic if all nodes from $$$S$$$ have the same color.
After each query, print the number of connected monochromatic subsets (modulo $$$998\,244\,353$$$, obviously).
The first line contains two integers $$$n$$$ and $$$q$$$ $$$(2 \le n \le 2 \times 10^5, 1 \le q \le 2 \times 10^5)$$$ — the size of the tree and the number of queries.
The second line contains $$$n$$$ integers $$$c_1, c_2, \ldots, c_n$$$ $$$(0 \le c_i \le 1)$$$ — initial colors of nodes.
The next $$$n - 1$$$ lines contain two integers $$$v$$$ and $$$u$$$ $$$(1 \le v, u \le n)$$$ — edges of the tree.
The next $$$q$$$ lines contain one integer $$$v$$$ $$$(1 \le v \le n)$$$ — node from the query.
Print $$$q$$$ integers — the number of connected monochromatic subsets modulo $$$998\,244\,353$$$ after each query.
6 51 0 0 0 0 14 34 51 22 44 612542
18 9 7 13 10
| Name |
|---|


