// Arup Guha
// 12/18/2012
// Solution to 2010 Mercer Contest Problem Word Stats(prob3)
import java.util.*;

public class prob3 {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Use two different lists, since the stats are computed in two different ways.
		ArrayList<item> list = new ArrayList<item>();
		ArrayList<String> list2 = new ArrayList<String>();

		// Read in each word, one at a time and update each list accordingly.
		while (stdin.hasNext()) {
			String input = stdin.next();
			String word = convert(input);
			list2.add(word);
			update(word, list);
		}

		// Sort both lists.
		Collections.sort(list);
		Collections.sort(list2);

		// Print the output.
		printMedian(list2);
		printMode(list);
	}

	// Updates list to account for one new occurrence of word.
	public static void update(String word, ArrayList<item> list) {

		boolean flag = false;
		int i = 0;

		// Go through and see if word is already in list. If so, add one to its frequency.
		for (i=0; i<list.size(); i++) {
			if (list.get(i).equals(word)) {
				flag = true;
				list.get(i).addOne();
				break;
			}
		}

		// If word wasn't in the list, add it as a new word.
		if (!flag) {
			list.add(new item(word));
		}
	}

	// Return a version of input stripping all non alphabetic characters.
	public static String convert(String input) {

		// Count the number of alphabetic characters.
		int cnt = 0;
		for (int i=0; i<input.length(); i++)
			if (Character.isLetter(input.charAt(i)))
				cnt++;

		char[] ans = new char[cnt];
		int j = 0;

		// Copy in each letter.
		for (int i=0; i<input.length(); i++) {
			if (Character.isLetter(input.charAt(i))) {
				ans[j] = input.charAt(i);
				j++;
			}
		}

		// Return its lowercase version.
		String retval = new String(ans);
		return retval.toLowerCase();

	}

	// Given a sorted list (by frequency), the modes are printed.
	public static void printMode(ArrayList<item> list) {

		// Beginning of output.
		System.out.print("My mode=[");

		// Go through the list so long as each item equals the max frequency and print.
		int best = list.get(0).freq;
		int i=0;
		while (i < list.size() && list.get(i).freq == best) {
			if (i > 0)
				System.out.print(",");
			System.out.print(list.get(i).word+"("+best+")");
			i++;
		}

		// Finish the output.
		System.out.println("]");
	}

	// Given a sorted list (with multiple occurences of words in alpha order), print the median(s).
	public static void printMedian(ArrayList<String> list) {

		// Split our work into even and odd cases.
		int n = list.size();
		if (n%2 == 1) {
			System.out.println("My median=["+list.get(n/2)+"]");
		}
		else {
			System.out.println("My median=["+list.get(n/2-1)+","+list.get(n/2)+"]");
		}
	}
}

// Used for mode.
class item implements Comparable<item> {

	public String word;
	public int freq;

	// Each item has a word and a frequency.
	public item(String w) {
		word = w;
		freq = 1;
	}

	public void addOne() {
		freq++;
	}

	// Sort by frequency, breaking ties alphabetically.
	public int compareTo(item other) {
		if (this.freq != other.freq)
			return other.freq - this.freq;
		return this.word.compareTo(other.word);
	}

	// Checks for equality between other and this object.
	public boolean equals(String other) {
		return this.word.equals(other);
	}
}