class Data: def __init__(self, id_team, id_univ, ac, ue, pena): self.id_team = id_team self.id_univ = id_univ self.ac = ac self.ue = ue self.pena = pena def __lt__(self, other): if self.ac != other.ac: return self.ac > other.ac if self.ue != other.ue: return self.ue < other.ue return self.pena < other.pena def printMembers(self): print(self.id_team, self.id_univ, self.ac, self.ue, self.pena) N, K = map(int, input().split()) teams = [] for i in range(N): s, p, u = map(int, input().split()) teams.append(Data(i, u, s, 0, p)) teams.sort() # for p in teams: # p.printMembers() # print() MAX_UNIV = 100001 cnt_ue = [0] * MAX_UNIV for team in teams: team.ue = cnt_ue[team.id_univ] cnt_ue[team.id_univ] += 1 teams.sort() # for p in teams: # p.printMembers() for team in teams[:K]: print(team.id_team)