// Arup Guha
// 6/2/2013
// Solution to 2013 KTH Challenge Problem I: Flag Quiz

import java.util.*;

public class flagquiz {

	public static int n;
	public static String[] lines;
	public static String[][] toks;

	public static void main(String[] args) {

		// Get input.
		Scanner stdin = new Scanner(System.in);
		String q = stdin.nextLine();
		n =	Integer.parseInt(stdin.nextLine().trim());
		lines = new String[n];
		toks = new String[n][];

		// Parse Input, remove leading spaces from each option except first.
		for (int i=0; i<n; i++) {
			lines[i] = stdin.nextLine();
			StringTokenizer tok = new StringTokenizer(lines[i],",");
			toks[i] = new String[tok.countTokens()];
			toks[i][0] = tok.nextToken();
			for (int j=1; j<toks[i].length; j++)
				toks[i][j] = tok.nextToken().substring(1);
		}

		// worst case.
		int nC = toks[0].length;

		// Try each one count which one it has the most differences with.
		for (int i=0; i<n; i++) {
			int cur = 0;
			for (int j=0; j<n; j++)
				cur = Math.max(cur, changes(i,j));
			nC = Math.min(nC, cur);
		}

		// Redo, for output.
		for (int i=0; i<n; i++) {
			int cur = 0;
			for (int j=0; j<n; j++)
				cur = Math.max(cur, changes(i,j));

			// Only output if this ties the best.
			if (cur == nC)
				System.out.println(lines[i]);
		}
	}

	// Returns # of non-matching corresponding entitites in item i and item j.
	public static int changes(int i, int j) {
		int res = 0;
		for (int loop=0; loop<toks[i].length; loop++)
			if (!toks[i][loop].equals(toks[j][loop]))
				res++;
		return res;
	}
}
