The British spy agency MI6 is planning to infiltrate a network of double agents into the sinister criminal organisation SPECTRE. SPECTRE has $$$N$$$ employees, numbered from $$$0$$$ to $$$N-1$$$, and their organisation chart is a tree on these $$$N$$$ vertices.
MI6 will select a non-empty set $$$S$$$ of SPECTRE employees to turn into double agents. Because of the risk of further treachery (i.e. possible triple-agents), it is essential that the chain of communication between any two double-agents passes only through 'innocent' employees. That is, for any two distinct employees $$$a$$$ and $$$b$$$ in $$$S$$$, the simple path between $$$a$$$ and $$$b$$$ in the tree must not contain any other employees in $$$S$$$.
Your task is to count the number of possible sets $$$S$$$ of double agents. Since this value can be quite large, output the value modulo $$$10^9 + 7$$$.
Implementation Details
You will have to submit a single .cpp source file.
Among this task's attachments you will find a template trees.cpp with a sample implementation.
You have to implement the following function:
int count_sets(int N, vector<int> U, vector<int> V);
The grader will call the function count and will print its return value to the output file.
The task's directory contains a simplified version of the jury grader, which you can use to test your solution locally. The simplified grader reads the input data from stdin, calls the functions that you must implement, and finally writes the output to stdout.
The input is made up of $$$N$$$ lines, containing:
Constraints
The output is made up of a single line, containing the value returned by the function count.
Your program will be tested on a set of test cases grouped by subtask. To obtain the score associated to a subtask, you need to correctly solve all the test cases it contains.
3 0 1 1 2
6
5 0 1 0 2 1 3 1 4
17
In the first sample case, the tree is a path $$$(0 - 1 - 2)$$$. There are $$$6$$$ possible sets in this tree: $$$\{0\}, \{1\}, \{0, 1\}, \{2\}, \{0, 2\}, \{1, 2\}$$$.
The set $$$\{0, 1, 2\}$$$ is not permitted as $$$1$$$ lies on the simple path between $$$0$$$ and $$$2$$$.
In the second sample case, the tree is a path $$$(3 - 1 - 0 - 2)$$$ with a single additional leaf $$$(4)$$$. There are $$$17$$$ possible sets in this tree.
| Name |
|---|


