Problem A

Los Vegos

The city of Los Vegos is known as the "Casino of the World" and gambling is its main industry. To guarantee that the city keeps its reputation as the place where gambling is fair, Los Vegos gambling authorities control casinos very tightly.

To this end, every casino must keep a log of the game results for each of its slot machines. Gambling authorities inspect these logs, searching for repeated sequences of results (which suggest a mechanical problem in the machine).

As a programmer expert, you are asked to write a program to find the most frequent sequence of N results in a log of results.

Problem

Given an integer N (0 < N < 40) and a log of a slot machine results, find the most frequent sequence of N results in the log.

Input

The first line contains an integer N (0 < N < 40), which specifies the length of the sequences to consider.

The second line contains an integer R (N <= R <= 40000), which represents the number of results in the log.

Each of the following R lines contains one slot machine result.

A slot machine result is a sequence of 3 letters. Each letter belongs to the set {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'}, and denotes the final position of the corresponding reel.

Output

The output consists of N + 1 lines.

The first line contains the number of times the most frequent sequence appears.

The next N lines contain the most frequent sequence of results, with one result in each line.

If there is a tie, the sequence whose first occurrence occurs first in the log must be returned.

Sample Input

2
10
AFB
BDE
CBA
AFB
BDE
CBA
BDE
CBA
AFB
BDE

Sample Output

3
AFB
BDE


CPN'2003: 1st Concurso de Programação da Nova --- 2nd Leg
Departamento de Informática
Faculdade de Ciências e Tecnologia
Universidade Nova de Lisboa