
131  ZOJ Monthly, March 2014  A
Alice and Bob both love playing games. Now, Alice and Bob are playing a cue sport like Nineball Pool. Two players move in turn. A move is that one player use the cue ball to hit the target ball for pocketing the target ball. At the beginning of game, there are one cue ball and n object balls. Each object ball has a number (a positive integer) on it, and no two object balls have the same number. In a move, the target ball is a object ball still on the table with the smallest number. If the player does the following things in a move, a foul is called and a penalty point is added to the opposite's point:
Now given n object balls and m moves, Bob wants to write a program to calculate the final points of Alice and him after these m moves. Because of Lady's first Rule, Alice always moves first. InputThere are multiple cases. The first line of each case consists of two integers, n and m (1 ≤ n ≤ 1000, 0 ≤ m ≤ 1000), as described above. The second line consists of n positive integers. Each integer a_{i} means the number of i^{th} object ball (1 ≤ a_{i} ≤ 10000). There are 2m lines followed. The (2i1)^{th} and (2i)^{th} lines describe the i^{th} move. The (2i1)^{th} line first includes an integer p, meaning cue ball hits p balls first. There are p integers followed in the same line, describing the hit balls. The (2i)^{th} line first includes an integer q, meaning there are q balls pocketed. There are q integers followed in the same line, describing the pocketed balls (0 means cue ball). It's guaranteed that there is no impossible data. OutputFor each case, output one line as the format: "AP : BP", where AP means Alice's points and BP means Bob's points. Sample Input3 3 2 3 5 1 2 1 2 1 3 1 5 1 3 1 3 Sample Output2 : 8 Author: YU, Xiaoyao 