408203: GYM103053 B Spelling Error

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Spelling Errortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You have watched all of Gura's streams since her debut in Hololive EN. You want to learn what her favourite food is. In order to do so, you jot down her favourite food every time she shows its name on stream. However, she can't seem to make up her mind on one favourite food, so sometimes the food she says may differ. Furthermore, Gura is notorious for misspelling words, so even the spelling of the same food may differ!

You have collected a list of strings $$$S_1, S_2, \dots, S_N$$$ ($$$1 \leq N$$$), which are mentioned in Gura's streams. All of the strings have a fixed length of $$$K \geq 2$$$. The score of a string $$$S_i$$$ is defined as the number of strings $$$S_j$$$ ($$$i$$$ and $$$j$$$ can be the same) such that $$$S_i$$$ and $$$S_j$$$ differ by at most one letter. More formally, $$$S_i = \overline{a_1a_2a_3\dots a_K}$$$ and $$$S_j=\overline{b_1b_2b_3\dots b_K}$$$ differ by $$$x$$$ letters if there are exactly $$$x$$$ distinct $$$idx$$$'s such that $$$a_{idx}\neq b_{idx}$$$.

Output a string $$$S_i$$$ with maximum score. If there are multiple such strings, output the lexicographical smallest string. Additionally, you should output the number of strings $$$S_i$$$ that can attain the maximum score.

Input

The first line consists of two integers, $$$N$$$ and $$$K$$$ $$$(N \times K \leq 2 \times 10^{5})$$$, denoting the number of strings that you have jotted down and the fixed length of each string respectively.

The next $$$N$$$ lines each contain a string $$$S_i$$$ with length $$$K$$$, composed of only lowercase English alphabet ('a'-'z').

Output

The first line consists of one string, which has the maximum score.

The second line consists of the number of strings that can attain the maximum score.

Scoring

Subtask $$$1$$$ ($$$19$$$ points): $$$N \leq 100$$$

Subtask $$$2$$$ ($$$47$$$ points): $$$K \leq 10$$$

Subtask $$$3$$$ ($$$34$$$ points): No additional constraints

ExampleInput
5 5
takos
tacos
fishy
aaaaa
fisty
Output
fishy
4
Note

In the sample, "takos" and "tacos" differ by one letter, so is "fishy" and "fisty". The other pairs all differ by more than one letter. The score for the strings are all $$$2$$$ except for "aaaaa", which has a score of $$$1$$$. There are $$$4$$$ strings in total with maximum score of $$$2$$$, and "fishy" is the lexicographically smallest among them.

加入题单

算法标签: