23 lines
552 B
Python
23 lines
552 B
Python
|
def main():
|
||
|
N, K = [int(i) for i in input().split()]
|
||
|
things = [input() for _ in range(3*N)]
|
||
|
|
||
|
occ = {}
|
||
|
|
||
|
for i in range(len(things)):
|
||
|
t = things[i]
|
||
|
if t not in occ:
|
||
|
occ[t] = (0, i)
|
||
|
occ[t] = (occ[t][0]+1, i)
|
||
|
|
||
|
# nb d'apparition, date de première apparition, texte
|
||
|
data = [(occ[i][0], occ[i][1], i) for i in occ.keys()]
|
||
|
data.sort(key=lambda x: (x[0], x[1]), reverse=True)
|
||
|
|
||
|
cursor = 0
|
||
|
while cursor < K and cursor < len(data):
|
||
|
print(data[cursor][2])
|
||
|
cursor += 1
|
||
|
|
||
|
|
||
|
main()
|