// Arup Guha
// 3/23/2026
// Solution to COP 3330 Program #7

import java.util.*;

public class MakeRunOff {

	public static void main(String[] args) {
	
		// Get basic information.
		Scanner stdin = new Scanner(System.in);
		StringTokenizer line = new StringTokenizer(stdin.nextLine());
		int numPrecincts = Integer.parseInt(line.nextToken());
		int minVotes = Integer.parseInt(line.nextToken());
		
		HashMap<String,Integer> votes = new HashMap<String,Integer>();
		
		// Go through each precinct.
		for (int i=0; i<numPrecincts; i++) {
		
			// Go through each vote from this precinct.
			line = new StringTokenizer(stdin.nextLine());
			while (line.countTokens() > 0) {
				String person = line.nextToken();
				
				// New person, add to map.
				if (!votes.containsKey(person))
					votes.put(person, 1);
					
				// Just update map.
				else
					votes.put(person, votes.get(person)+1);
			}
		}
		
		// Extract all the good vote getters and sort.
		ArrayList<String> madeIt = new ArrayList<String>();
		for (String p: votes.keySet())
			if (votes.get(p) >= minVotes)
				madeIt.add(p);
		Collections.sort(madeIt);
		
		// Ta da!
		for (int i=0; i<madeIt.size(); i++)
			System.out.println(madeIt.get(i));
	}
}