1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10008 - What's Cryptanalysis?
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=949
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.076
*/

import java.io.*;
import java.util.*;

class Main {

public static void main(String...args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int lines = Integer.parseInt(reader.readLine());

int[] stat = new int[26];
Map<Integer, Set<Character>> map = new TreeMap<Integer, Set<Character>>(Collections.reverseOrder());


String input;
for(int l = 0; l < lines; l++)
{
input = reader.readLine();
input = input.toUpperCase();

for(int i = 0; i < input.length(); i++)
if(Character.isLetter(input.charAt(i)))
stat[input.charAt(i)-'A']++;
}

for(int i = 0; i < 26; i++)
if(stat[i] > 0)
{
if(map.get(stat[i]) == null)
map.put(stat[i], new TreeSet<Character>());
map.get(stat[i]).add((char)(i+'A'));
}

//System.out.println(map);
for(int i : map.keySet())
for(char c : map.get(i))
System.out.println(c + " " + i);
}
}