Taylor Swift! tswift.X The cows won a Taylor Swift concert! Well, tired from her recent stint in Claremont, Taylor has agreed not to a concert, but to a low-key evening of Smoothie-making, during which she describes the different milk-based beverages that inspire her songs. Since the cows appreciate milk (and Taylor does not speak Moo), this seems like a perfect opportunity for both! Taylor will need a large number of ingredients to create specialized smoothies for her audience. Fortunately, Farmer John has H (1 <= H <= 1000) different types of hay available at his barn. Those types of hay are conveniently numbered 1..H and each type has some integer price (range: 1..10,000). That price provides as much hay of that particular flavor as needed. The cows have a list of S (1 <= S <= 1000) smoothies that they are contemplating requesting at the TSwiftSmoothieSmash, which is co-sponsored by a philanthropic college-smoothie-website named "Chugg." Each smoothie's recipe has a 'flavor value' allowing Chugg to sell it for an integer price in the range from 1 to 10,000. Each recipe requires a particular subset of the different hay types; the total number of requirement (haytype, flavor) pairs is at most 10,000. The cows want to maximize the revenue they, Taylor, and Chugg can generate from their smoothie recipes. That revenue is calculated as the sum of the values of all the completed smoothie recipes minus the sum of the cost of all the ingredients purchased. Again, the cows only need to purchase an ingredient once and can, if they wish, use it for multiple smoothies. What is the maximum profit the cows can make? PROBLEM NAME: tswift INPUT FORMAT: * Line 1: Two space-separated integers: H and S * Lines 2..H+1: Line i+1 a single integer that is the price of ingredient (hay) i * Lines H+2..H+S+1: Each line contains several space-separated integers that describe a smoothie recipe that can be concocted. The first integer is the value of the recipe upon completion. The second integer is the number of ingredients required, N. The next N integers are unique and compose the list of required ingredients. SAMPLE INPUT: 4 3 2 3 4 5 3 2 1 2 4 3 1 3 4 7 2 2 3 OUTPUT FORMAT: * Line 1: A single integer that is the maximum profit that cows can make. SAMPLE OUTPUT: 1