Problem Statement:
Saad Nabiha has built his own website, and he is about to launch it. This is really exciting!

But first he has to convince investors how important his website is, and how much ad revenue it can generate. But they are not convinced easily; they want numbers. Investors want to know what is the largest revenue Saad can get from a single user in a single session. Here is how ads on Saad's website work: Saad has N pages in his website, each one containing zero or more hyperlinks pointing to other pages. A user starts his session from any page, and navigates Saad's website by following the hyperlinks (but unfortunately no back button) for a while, and then leaves. When a user visits a page p of Saad's website, Saad receives Ap cents of revenue. A user might visit the same webpage multiple times, but Saad will receive the revenue of a page once only per session.

Could you help Saad find the maximum revenue he can get?

Input Format:
Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1  ≤  T  ≤  100). Each test case starts with a line that contains an integer N (1  ≤  N  ≤  50,000) , the number of pages. Then N lines follow. Each line will contain an integer Ap (1  ≤  Ap  ≤  10,000) the revenue, and an integer M, the number of hyperlinks in the current page, followed by M integers. The list of indices of the webpages themselves. No page links to itself, and no page has more than one link to the same page.

Output Format:
For each test case print a single line containing "Case n:" (without the quotes) where n is the test case number (starting from 1) followed by a single space, followed by the maximum revenue from a single user in a single session.

Sample Input:
2 3 10 0 10 2 0 2 10 1 1 5 5 0 5 2 0 3 8 1 1 7 0 3 0

Sample Output:
Case 1: 30 Case 2: 20

Added by: ahmed_aly
Added at: 2014-10-11 15:00:04 UTC
Time Limit: 3 seconds
Partial score: No
Source:ACM Egyptian Collegiate Programming Contest 2014