You are given a tree with no root. Each node has one integer written on it.
Write a program that counts the ways to decompose the tree into a set of paths. A decomposition has to satisfy both conditions below.
- Every node belongs to exactly one path.
- The sum of the integers written on the nodes of a path is nonnegative.
A path here is a subgraph whose nodes are joined one after another along the edges of the tree, and a path that holds a single node counts as a path. Two decompositions are different when they group the nodes differently.