Under construction

Still being built. Things may change

Basketball

Interview

Time limit1sMemory limit1024 MB

Summary
Simulate m substitutions between the odd-position and even-position teams, then list the players on the court in alphabetical order.
Level

Easy3 of 10

Topics
Simulation, Sorting
Solved
No attempts yet

Problem

During physical education, the students of class 10-A play basketball. The class has nn students who stand in a row. The PE teacher splits them into two teams as follows: the first team gets the students standing in odd positions (first, third, fifth, and so on). The students in even positions (second, fourth, sixth, and so on) form the second team.

Each team always has pp students on the court. At the start, the pp students standing earliest in the original line from each team go on the court. So that every student gets to play, the teacher makes substitutions in both teams every minute.

The player who has spent the most minutes on the court so far (not necessarily consecutively) goes to the bench. If several players are tied, the one with the largest number in the original line goes to rest.

The bench player who has spent the fewest minutes on the court so far comes onto the court. If several are tied, the one with the smallest number in the original line comes in.

The teacher wants to know who will be on the court after mm substitutions. Help him find out.

For example, suppose six students stand in this order: Ivanov, Petrov, Sidorov, Andreev, Kazakov, Sergeev. The teams are formed as follows. First team: Ivanov, Sidorov, Kazakov. Second team: Petrov, Andreev, Sergeev. Suppose 2 players are on the court at once. Then at the start Ivanov and Sidorov from the first team and Petrov and Andreev from the second team take the court.

After the first minute, Sidorov and Andreev go to the bench, and Kazakov and Sergeev come on. After the second minute, Ivanov and Petrov rest, and Sidorov and Andreev return. After the third minute, Kazakov and Sergeev rest again, and Sidorov and Andreev come on. So after three substitutions the court has (in alphabetical order) Andreev, Ivanov, Petrov, and Sidorov.

Input

The first line contains three integers nn, mm, and pp (2p≤n≤502p \le n \le 50, 1≤p≤101 \le p \le 10, 0≤m≤1000 \le m \le 100). The next nn lines each contain one surname, the players in the order they originally stood in the line. Each surname is a non-empty string of Latin letters, at most 50 characters long. All surnames are distinct.

Output

Print the surnames of the players who are on the court after mm substitutions, in alphabetical order. Separate the surnames with spaces.

Examples1

  1. Example 1

    Input
    6 3 2
    Ivanov
    Petrov
    Sidorov
    Andreev
    Kazakov
    Sergeev
    
    Expected output
    Andreev Ivanov Petrov Sidorov