AT_abc446_b [ABC446B] Greedy Draft

Description

There are $ N $ customers numbered $ 1 $ to $ N $ , and $ M $ canned juices numbered $ 1 $ to $ M $ . Customer $ i $ ( $ 1 \leq i \leq N $ ) has a wish list of length $ L_i $ . The $ j $ -th item ( $ 1 \leq j \leq L_i $ ) from the top of customer $ i $ 's wish list is canned juice $ X_{i,j} $ . For any customer $ i $ , the numbers $ X_{i, 1}, \dots, X_{i, L_i} $ on customer $ i $ 's wish list are distinct. Customers $ 1, \dots, N $ , in this order, will now choose their beverages, following the procedure below. - If the customer's wish list contains a canned juice that has not yet been chosen by anyone at that point, they choose the canned juice whose number appears earliest in their wish list. Otherwise, they choose water. Determine which beverage each customer gets.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ M $ $ L_1 $ $ X_{1,1} $ $ X_{1,2} $ $ \cdots $ $ X_{1,L_1} $ $ L_2 $ $ X_{2,1} $ $ X_{2,2} $ $ \cdots $ $ X_{2,L_2} $ $ \vdots $ $ L_N $ $ X_{N,1} $ $ X_{N,2} $ $ \cdots $ $ X_{N,L_N} $

Output Format

Output $ N $ lines. The $ i $ -th line ( $ 1 \leq i \leq N $ ) should contain the number of the canned juice customer $ i $ gets if they get one, or `0` if customer $ i $ gets water.

Explanation/Hint

### Sample Explanation 1 Among the numbers on customer $ 1 $ 's wish list, the canned juices not yet chosen by anyone are $ 3, 1, 2 $ . The one appearing earliest in the list is $ 3 $ , so customer $ 1 $ chooses canned juice $ 3 $ . Among the numbers on customer $ 2 $ 's wish list, the canned juices not yet chosen by anyone are $ 2, 1 $ . The one appearing earliest in the list is $ 2 $ , so customer $ 2 $ chooses canned juice $ 2 $ . For the numbers on customer $ 3 $ 's wish list, all corresponding canned juices have already been chosen by someone at that point. Thus, customer $ 3 $ chooses water. Among the numbers on customer $ 4 $ 's wish list, the canned juices not yet chosen by anyone are $ 5, 1 $ . The one appearing earliest in the list is $ 5 $ , so customer $ 4 $ chooses canned juice $ 5 $ . ### Constraints - $ 1 \leq N \leq 100 $ - $ 1 \leq M \leq 100 $ - $ 1 \leq L_i \leq M $ ( $ 1 \leq i \leq N $ ) - $ 1 \leq X_{i,j} \leq M $ ( $ 1 \leq i \leq N $ , $ 1 \leq j \leq L_i $ ) - $ X_{i, 1}, \dots, X_{i, L_i} $ are distinct. ( $ 1 \leq i \leq N $ ) - All input values are integers.