Rar the Cat is having a basketball session today and his teacher has appointed 4 group leaders to choose their respective group members from a pool of N remaining students, forming 4 teams of exactly K team members (excluding the leader).
The 4 groups are conveniently labelled group A, group B, group C and group D. The leaders have discussed about this and decided that they will select members for their team in order. Group A will go first followed by Group B then C then D. After Group D selects his member for the first round, it will be back to Group A's turn to select another member. This sequence continues until all N students are allocated to a group.
Rar the Cat knows that each group leader has different criteria for selecting people and they will definitely choose the most desired member out of the remaining pool of unselected students. Hence, in order to automate the grouping process, Rar the Cat has asked the group leaders to rank the N students based on how much they want them to be in their team. If a student gets a ranking of 1, it means he is the most desired member while if he gets a ranking of N, he is the least desired member.
For convenience, each student is assigned a unique number from 1 to N, known as the student identification number.
The first line of input consists of 2 integers, N followed by K. It is noted that N will always be 4 times of K.
The following N lines of input will consist of 4 integers each. The ith line will describe the ranking for the ith student (with a student identification number i.
The first integer will be the ranking of the student by group A's leader, followed by B, C then D.
You are to output 4 lines of K integers each to standard output.
The first line represents group A and the second line represents group B. Similarily, the third line represents group C and the last line represents group D.
For each line, you are to print the student idenification numbers of the students in the group. Please print them in ascending order with a single space in between consecutive numbers.
Subtask 1 (37%): 0 < K ≤ 1000
Subtask 2 (63%): 0 < K ≤ 100000
12 3 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 1 3 4 5 6 7 8 9 10 11 12 1 2 4 5 6 7 8 9 10 11 12 1 2 3
1 4 5 7 8 12 9 10 11 2 3 6
The grouping will be conducted in the following sequential order:
Group A chooses student 1, B chooses student 12, C chooses student 9, D chooses student 6.
Group A chooses student 4, B chooses student 7, C chooses student 10, D chooses student 2.
Group A chooses student 5, B chooses student 8, C chooses student 11, D chooses student 3.