Count DFS Tree
시간 제한1초메모리 제한2048 MB
모든 잎이 깊이 K에 있는 n개 노드 트리에서 DFS 반환 수열의 서로 다른 가짓수를 구하고, M개 질의의 값을 곱해 출력한다.
문제
You are currently studying a tree traversal algorithm called the Depth First Search (DFS). Suppose you have a rooted tree of nodes (numbered from to ) with a depth of (numbered from to ). The root (the node at depth ) is located at node . All leaves are located at the same depth, that is, at depth . Node has an array of children nodes , which could be empty if is a leaf node. The pseudocode of the algorithm is presented as follows.
DFS(u, depth):
let res be an empty array
append depth to res
for each v in c[u]:
let D be an array initialized with DFS(v, depth + 1)
for each x in D:
append x to res
return res
Consider the trees in the following illustration. The return values of DFS(1, 1) for the tree on the left and the tree on the right are and , respectively.

Denote as the number of distinct return values of DFS(1, 1) across all trees consisting of nodes and all leaves are located in depth . You are given integers: . Determine the value of . As the answer can be very large, find the answer modulo .
입력
The first line consists of two integers ().
The following line consists of integers ().
출력
Output a single integer representing the value of modulo .