#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stdlib.h>

using namespace std;

long N;
char words[5000][51];
long word_len[5000];
long longest_word=0;
size_t words_lex[5000];
size_t wl_sorted[5000];

size_t slavko_best;
size_t slavko_best_len=1000;

long myheap[5];

// ima neka tajna veza...
struct veza {
	char from;
	char to;
	char owner;
	char win;
	size_t word;
};

//char tree[5000][26];
veza veze[51][700];
size_t veze_count[51];
//bool tree_connct[

bool cmp(size_t a, size_t b) {
	return strcmp(words[a], words[b]) == -1;
}

bool cmp2(size_t a, size_t b) {
	if (word_len[a] == word_len[b]) return (strcmp(words[a], words[b]) == -1);
	return (word_len[a] < word_len[b]);
}


bool isPossibleS(size_t wrd, long startLevel) {
	printf("Slavko proba %s, level %d\n", words[wrd], startLevel);
	long wrdlen = word_len[wrd];
	long level = 2;
	bool doWord[51];
	memset(doWord, 1, 51);
	while (level < wrdlen) {
		for (long veza_loop=0; veza_loop<veze_count[level]; veza_loop++) {
			if ((doWord[veze[level][veza_loop].word]) && (words[wrd][0]==words[veze[level][veza_loop].word][0])) {
				if ((veze[level][veza_loop].from == words[wrd][level-1]) && (veze[level][veza_loop].word != wrd) && (word_len[veze[level][veza_loop].word]<wrdlen)) {
					printf("level %d, word %s, win %c, %c:\t%c -> %c\n", level, words[veze[level][veza_loop].word], veze[level][veza_loop].win, veze[level][veza_loop].owner, veze[level][veza_loop].from, veze[level][veza_loop].to);
//					if (word_len[veze[level][veza_loop].word] > wrdlen) return false;
					if ((level>=startLevel) && (veze[level][veza_loop].win == 'M')) return false;
				} else {
					doWord[veze[level][veza_loop].word] = false;
				}
			}
		}
		level += 2;
	}
	if (wrdlen<slavko_best_len) {
		slavko_best_len = wrdlen;
		slavko_best = wrd;
	}
	return true;
}

bool isPossible(size_t wrd) {
	printf("%s\n", words[wrd]);
	long wrdlen = word_len[wrd];
	long level = 1;
	bool doWord[51];
	memset(doWord, 1, 51);
	while (level < wrdlen) {
		for (long veza_loop=0; veza_loop<veze_count[level]; veza_loop++) {
			//printf("level %d, word %s, win %c, %c:\t%c -> %c\n", level, words[veze[level][veza_loop].word], veze[level][veza_loop].win, veze[level][veza_loop].owner, veze[level][veza_loop].from, veze[level][veza_loop].to);
			if (doWord[veze[level][veza_loop].word]) {
				if ((veze[level][veza_loop].from == words[wrd][level-1]) /*&& (veze[level][veza_loop].word != wrd)*/) {
					printf("level %d, word %s, win %c, %c:\t%c -> %c\n", level, words[veze[level][veza_loop].word], veze[level][veza_loop].win, veze[level][veza_loop].owner, veze[level][veza_loop].from, veze[level][veza_loop].to);
					if (veze[level][veza_loop].win == 'S') {
						if (isPossibleS(veze[level][veza_loop].word, level+1)) return false;
						printf("Slavko ne moze\n");
					}
					if (word_len[veze[level][veza_loop].word] > wrdlen) return false;
				} else {
					doWord[veze[level][veza_loop].word] = false;
				}
			}
		}
		level += 2;
	}
	return true;
}


int main(int argc, char *argv[])
{
	memset(words, 0, 5000*51);
	memset(veze_count, 0, 51*4);
	
	FILE *fin = fopen("igra.in", "r");
	fscanf(fin, "%d\n", &N);
	long subN = 0;
	long writePos=0;
	for (long loop_N=0; loop_N<N; loop_N++) {
		fscanf(fin, "%s\n", words[writePos]);
		long wl = strlen(words[writePos]);
		if (wl > 1) {
			word_len[writePos] = wl;
			if (wl>longest_word) longest_word = wl;
			words_lex[writePos] = writePos;
			wl_sorted[writePos] = writePos;
			writePos++;
		} else subN++;
	}
	fclose(fin);
	N -= subN;
	
	std::sort(&words_lex[0], &words_lex[N], cmp);
	std::sort(&wl_sorted[0], &wl_sorted[N], cmp2);
	
	for (long loop_N=0; loop_N<N; loop_N++) {
		printf("%s\n", words[wl_sorted[loop_N]]);
	}
	
	for (long loop_N=0; loop_N<N; loop_N++) {
		for (long level = 1; level<longest_word; level++) {
			char curlett = words[words_lex[loop_N]][level];
			char prevlett = words[words_lex[loop_N]][level-1];
			//printf("%c -> %c\n", prevlett, curlett);
			if (curlett > 0) {
				veze[level][veze_count[level]].from = prevlett;
				veze[level][veze_count[level]].to = curlett;
				veze[level][veze_count[level]].owner = ((level%2)==1)?'S':'M';
				veze[level][veze_count[level]].win = ((word_len[words_lex[loop_N]]%2)==1)?'S':'M';
				veze[level][veze_count[level]].word = words_lex[loop_N];
				//printf("level %d, count %d, %c -> %c CREATED\n", level, veze_count[level], prevlett, curlett);
				veze_count[level]++;
			} else break;
		}
//		printf("\n");
	}

	for (long level = 0; level<longest_word; level++) {
		for (long lv = 0; lv<veze_count[level]; lv++) {
//			printf("level %d, count %d, word %d, win %c, %c:\t%c -> %c\n", level, lv, veze[level][lv].word, veze[level][lv].win, veze[level][lv].owner, veze[level][lv].from, veze[level][lv].to);
		}
//		printf("\n");
	}
	
	FILE *fout = fopen("igra.out", "w");
	bool hasBest = false;
	for (long loop_N=0; loop_N<N; loop_N++)	{
		//if ((word_len[wl_sorted[loop_N]]%2)==0) {
			/*printf("%d\n", isPossible(wl_sorted[loop_N]));
			printf("\n");*/
			if (isPossible(wl_sorted[loop_N])) {
				fprintf(fout, "1\n%s\n", words[wl_sorted[loop_N]]);
				hasBest = true;
				break;
			}
		//}
	}
	if (!hasBest) {
		fprintf(fout, "2\n%s\n", words[slavko_best]);
	}
	fclose(fout);
	//printf("%d\n", isPossible(5));
}
