You are given a tree and a constant K. The nodes of the tree are numbered from 1 to N. Each node in the tree has a value associated with it, A[i], where A[i] is either 0 or 1.
A tree is considered beautiful if the sum of its node values is equal to the given constant, K.
Georg wants to make the tree beautiful by removing any number of nodes (and their edges) from the tree, such that the tree still remains connected.
Your task is to count the number of ways to make the tree beautiful and print it modulo 10^9 + 7. Input format: Two integers N and K on the first line followed by the values of the N nodes in the next line. Lines 3 to (N + 1) contain the edges, where each pair of numbers indicates an undirected edge between those nodes.
0 1 0 1 1
Constraints: N <= 1e5, K <= 100
Please help me with this problem. It feels like a DP on trees problem, but I’m unable to find the recurrence.