#C5175. Most Frequent Letter

    ID: 48795 Type: Default 1000ms 256MiB

Most Frequent Letter

Most Frequent Letter

Given a list of phrases, your task is to determine the most frequent letter in each phrase.

For each phrase, let \( f(c) \) denote the frequency of letter \( c \) in the phrase. You are required to output the letter \( c \) that satisfies the following:

\[ c = \min\{ x \mid f(x)=\max_{y}f(y) \}\]

That is, if there are multiple letters with the same maximum frequency, choose the lexicographically smallest letter among them.

Note that each phrase contains only lowercase English letters.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains an integer \( n \), representing the number of phrases.
  2. Each of the next \( n \) lines contains a non-empty string consisting of lowercase English letters.

outputFormat

The output should be written to standard output (stdout) and consist of \( n \) lines. Each line should contain the most frequent letter of the corresponding phrase.

## sample
2
abacab
zzyyxx
a

x

</p>