You are given a tree with $$$n$$$ nodes and $$$n-1$$$ edges. Every edge $$$(u,v)$$$ has $$$w$$$ markable points. Each markable point can be marked at most once.
Each node $$$i$$$ has a permitted range $$$[l_i, r_i]$$$. Let $$$m_i$$$ denote the total number of marked points on edges incident to node $$$i$$$. For every node, the condition $$$l_i \le m_i \le r_i$$$ must hold.
You may choose any subset of nodes to supercharge. If node $$$i$$$ is supercharged:
If both nodes at the endpoints of an edge $$$(u,v)$$$ are supercharged, then the markable points on that edge reduces by 2 (1 because of each supercharged node).
You are allowed to mark at most $$$x$$$ points in total across the entire tree.
Your task is to compute the number of valid ways (respecting the permitted ranges of all nodes) to choose supercharged nodes and marked points, modulo $$$10^9 + 7$$$.
Two ways are considered identical if and only if:
The first line contains an integer $$$t$$$ $$$(1 \le t \le 250)$$$ — the number of test cases.
For each test case:
The first line contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 250$$$, $$$0 \le x \le 25$$$).
The next $$$n-1$$$ lines describe the edges. Each line contains three integers $$$a$$$, $$$b$$$, and $$$w$$$ ($$$1 \le a,b \le n$$$, $$$a \ne b$$$, $$$2 \le w \le 2 \cdot 10^5$$$), describing an edge between nodes $$$a$$$ and $$$b$$$ of length $$$w$$$. It is guaranteed that the edges provided form a valid tree.
The next $$$n$$$ lines each contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$0 \le l_i \le r_i \le x$$$), describing the permitted range of node $$$i$$$.
Additional Constraints:
For each test case, output a single integer, the number of valid ways modulo $$$10^9 + 7$$$.
42 11 2 20 10 12 21 2 21 20 23 11 2 101 3 200 11 10 05 101 2 101 3 92 4 152 5 71 31 21 20 20 2
843813510619
If an edge has 1 markable point, let its name be a, and if the edge has 2 markable points, let their names be a and b.
For the first test case:
For the second test case:
For the third test case:
We will refrain from manually listing out the possibilities of the fourth test case.