Problems
Wile lives alone in the desert, so he entertains himself by building complicated machines
that run on chain reactions. Each machine consists of
Modules that are not pointed at by any others are called initiators. Wile can manually trigger initiators. When a module is triggered, it triggers the module it is pointing at (if any) which in turn may trigger a third module (if it points at one), and so on, until the chain would hit the abyss or an already triggered module. This is called a chain reaction.
Each of the
For example, suppose Wile has

As seen above, if Wile manually triggers module

However, if Wile manually triggers module
Given the fun factors and the setup of the modules, compute the maximum fun Wile can get if he triggers the initiators in the best possible order.
Input
The first line of the input gives the number of test cases,
Output
For each test case, output one line containing Case #,
where
Example
3
4
60 20 40 50
0 1 1 2
5
3 2 1 4 5
0 1 1 1 0
8
100 100 100 90 80 100 90 100
0 1 2 1 2 3 1 3
Case #1: 110
Case #2: 14
Case #3: 490