Super Dango Maker

아직 제출이 없습니다시간 제한10초메모리 제한1024 MB

문제

JOI-kun is a professional confectioner making dangos (Japanese dumplings). In JOI-kun’s shop, the colors of dangos are specified. There are NN colors of dangos, numbered from 11 to NN.

A beautiful dango stick is a famous item in JOI-kun’s shop. A beautiful dango stick is made of NN dangos of different colors skewered with a stick.

For each of the NN colors, JOI-kun has MM dangos of that color. Therefore, JOI-kun has N×MN × M dangos in total. These dangos are numbered from 11 to N×MN × M. Using these dangos and MM sticks, JOI-kun wants to make MM beautiful skewered dango sticks.

To avoid a mistake about the colors of the dangos, JOI-kun will use a dango checker. If JOI-kun inputs the indices of some dangos, the dango checker answers the maximum number of beautiful dango sticks he can make using the dangos in the input and sufficiently many sticks.

Using the dango checker several times, JOI-kun wants to divide the N×MN × M dangos into MM groups. Every group should consist of NN dangos, and contain a dango of each color.

JOI-kun wants to divide the N×MN × M dangos into MM groups using the dango checker at most 50,00050\\,000 times.

Write a program which, given information of the dangos, implements JOI-kun’s strategy to divide the dangos into groups using the the dango checker at most 50,00050\\,000 times.

제한

All input data satisfy the following constraints. For the values of CC, see Input for the Sample Grader.

  • 1C_iN1 ≤ C\_i ≤ N (1iN×M1 ≤ i ≤ N × M).
  • For each jj (1jN1 ≤ j ≤ N), there are exactly MM indices ii (1iN×M1 ≤ i ≤ N × M) satisfying C_i=jC\_i = j.
  • NN, MM are integers.
  • C_iC\_i (1iN×M1 ≤ i ≤ N × M) is an integer.