Types: N: int, M: int, S: List[int], k: List[int], c: List[List[int]]
Ranges: 2 ≤ N ≤ 10,000, 1 ≤ M ≤ 1,000, 1 ≤ S[i] ≤ 100, 1 ≤ k[i] ≤ N, 1 ≤ c[i][j] ≤ N, Σk  ≤  100,000  
Addtl Info: The number of datasets does not exceed 30. The end of the input is indicated by a line containing two zeros.