Under construction

Still being built. Things may change

Nine Judges

Time limit2sMemory limit512 MB

Summary
Given n preference lists over k problems, output a p-subset that a random majority-driven swap process can return to infinitely often.
Level

Medium7 of 10

Topics
Graph, Greedy, Sorting
Solved
No attempts yet

Problem

There are kk problems proposed for the contest, and exactly pp of them must be chosen for the final problem set.

The problems have been evaluated by nn judges. Each judge has built their own preference list containing all the proposed problems, in order from the problem they like the most to the problem they like the least.

The XCPC finals are still far away, and nobody knows whether they will be held at all. The actual problem set is therefore chosen by an infinite procedure.

Initially, t=0t = 0 and S0S_0 contains pp problems chosen uniformly at random from the kk proposed problems. Then the following actions are repeated indefinitely:

  • Choose problems ii and jj uniformly at random such that i∈Sti \in S_t and j∉Stj \notin S_t.
  • If at least (n+1)/2(n+1)/2 judges have put jj before ii in their preference list, let St+1=St∖{i}∪{j}S_{t+1} = S_t \setminus \{i\} \cup \{j\}. Otherwise, let St+1=StS_{t+1} = S_t.
  • Increase tt by one.

A problem set SS is called plausible if there exists a positive probability threshold ε\varepsilon such that there are infinitely many moments tt when the probability of St=SS_t = S is more than ε\varepsilon. In formal notation:

SS is plausible   ⟺  ∃ε>0 ∀T≥0 ∃t≥T:P(St=S)>ε\iff \exists \varepsilon > 0\ \forall T \ge 0\ \exists t \ge T: P(S_t = S) > \varepsilon

Input

The first line contains three integers nn, kk, and pp (1≤n≤91 \le n \le 9; nn is odd; 1≤p<k≤50 0001 \le p < k \le 50\,000), the number of judges, the number of proposed problems, and the number of problems to choose.

Each of the following nn lines contains kk integers ai,1,ai,2,…,ai,ka_{i,1}, a_{i,2}, \ldots, a_{i,k} (1≤ai,j≤k1 \le a_{i,j} \le k, all values in a line are distinct). Here ai,1a_{i,1} is the problem the ii-th judge likes the most, ai,2a_{i,2} is the second most liked, and so on.

Output

Print pp distinct integers between 1 and kk in any order, denoting any plausible problem set.

Hint

In the example test case, some other possible answers are 1 2 5 and 2 4 5.

Examples1

  1. Example 1

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