output_description: Print N lines. In the i-th line, if it is possible to choose exactly i jewels,
  print the maximum possible sum of the values of chosen jewels in that case,
  and print -1 otherwise.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      C_1 V_1
      C_2 V_2
      :
      C_N V_N
attempt: giveup
  
problem_description: Statement
  
  There are N jewels, numbered 1 to N. The color of these jewels are represented
  by integers between 1 and K (inclusive), and the color of Jewel i is C_i.
  Also, these jewels have specified values, and the value of Jewel i is V_i.
  
  Snuke would like to choose some of these jewels to exhibit. Here, the set of
  the chosen jewels must satisfy the following condition:
  
    * For each chosen jewel, there is at least one more jewel of the same color that is chosen.
  
  For each integer x such that 1 \leq x \leq N, determine if it is possible to
  choose exactly x jewels, and if it is possible, find the maximum possible sum
  of the values of chosen jewels in that case.
samples: [{"input": "5 2\n    1 1\n    1 2\n    1 3\n    2 4\n    2 5", "output": "-1\n    9\n    6\n    14\n    15\n    \n\nWe cannot choose exactly one jewel.\n\nWhen choosing exactly two jewels, the total value is maximized when Jewel 4\nand 5 are chosen.\n\nWhen choosing exactly three jewels, the total value is maximized when Jewel 1,\n2 and 3 are chosen.\n\nWhen choosing exactly four jewels, the total value is maximized when Jewel 2,\n3, 4 and 5 are chosen.\n\nWhen choosing exactly five jewels, the total value is maximized when Jewel 1,\n2, 3, 4 and 5 are chosen.\n\n* * *"}, {"input": "5 2\n    1 1\n    1 2\n    2 3\n    2 4\n    2 5", "output": "-1\n    9\n    12\n    12\n    15\n    \n\n* * *"}, {"input": "8 4\n    3 2\n    2 3\n    4 5\n    1 7\n    3 11\n    4 13\n    1 17\n    2 19", "output": "-1\n    24\n    -1\n    46\n    -1\n    64\n    -1\n    77\n    \n\n* * *"}, {"input": "15 5\n    3 87\n    1 25\n    1 27\n    3 58\n    2 85\n    5 19\n    5 39\n    1 58\n    3 12\n    4 13\n    5 54\n    4 100\n    2 33\n    5 13\n    2 55", "output": "-1\n    145\n    173\n    285\n    318\n    398\n    431\n    491\n    524\n    576\n    609\n    634\n    653\n    666\n    678"}]