This page is still under construction.

Parts of this page are still being built. What you see may change.

Weekend Lottery

Time limit3sMemory limit128 MB

Summary
Given N past draws of C distinct numbers from 1 to K, print all numbers that appeared the fewest times, in increasing order.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

Your college classmates decided to organize a private lottery, with draws every Friday. A student who wants to bet chooses CC distinct numbers from 11 to KK and pays US $ 1.00 (traditional lotteries such as the US National Lotto use C=6C = 6 and K=49K = 49). On Friday during lunch, CC numbers (also from 11 to KK) are drawn. The student whose bet has the largest number of correct guesses receives the amount collected in the bets. This amount is shared in case of ties and accumulates to the next week if no one guessed any of the numbers drawn.

Some of your colleagues do not believe in the laws of probability and asked you to write a program that determines the numbers that have been drawn the fewest times over all previous draws, so that they can bet on those numbers.

Input

The input contains several test cases. The first line of a test case contains three integers NN, CC, and KK: the number of draws that have already happened (1≤N≤100001 \le N \le 10000), how many numbers make up a bet (1≤C≤101 \le C \le 10), and the maximum value of the numbers that can be chosen (C<K≤100C < K \le 100). Each of the next NN lines contains CC distinct integers XiX_i indicating the numbers drawn in that contest (1≤Xi≤K1 \le X_i \le K). The end of the input is indicated by N=C=K=0N = C = K = 0.

Output

For each test case, write one line containing the set of numbers that have been drawn the fewest times. Print this set as a list in increasing order, with a single space between two consecutive numbers.

Examples1

  1. Example 1

    Input
    5 4 6
    6 2 3 4
    3 4 6 5
    2 3 6 5
    4 5 2 6
    2 3 6 4
    4 3 4
    3 2 1
    2 1 4
    4 3 2
    1 4 3
    0 0 0
    
    Expected output
    1
    1 2 3 4