program igra;
type
niz = array [1..5200, 1..50] of char;
var
n, i, j, min, imin, k, t, jj : longint;
ime : string;
s : char;
A, d, p : array [1..5000] of longint;
R, RR : niz;
f, g : text;

procedure QSort(l,z, jj : integer; var R : niz);
var
i, j, k, x, yy : integer;
y : char;

begin
i := l;
j := z;
x := ord(R[(l+z) div 2,jj]);
repeat
        while (ord(R[i, jj]) < x) do i := i + 1;
        while (x < ord(R[j, jj])) do j := j - 1;
        if (i <= j) then
                begin
                for k := 1 to 50 do
                        begin
                        y := R[i][k];
                        R[i][k] := R[j][k];
                        R[j][k] := y;
                        end;
                yy := A[i];
                A[i] := A[j];
                A[j] := yy;
                i := i + 1;
                j := j - 1;
                end;
until (i > j);

if (l < j) then QSort(l, j, jj, R);
if (i < z) then QSort(i, z, jj, R);
end;

begin
assign(f, 'igra.in');
assign(g, 'igra.out');
reset(f);
rewrite(g);

readln(f, n);
for i := 1 to n do
        begin
        readln(f, ime);
        d[i] := length(ime);
        A[i] := d[i];
        for j := 1 to d[i] do R[i,j] := ime[j];
        end;

jj := 1;
QSort(1,n, 1, R);


R[n+1, 1] := ' ';

S := R[1,1];
j := 1;
for i := 2 to (n+1) do
        begin
        if (R[i, 1] <> S) then
                begin
                S := R[i,1];
                t := 0;
                for k := j to (i-1) do
                        if (A[k] mod 2 <> 0) then t := 1;
                for k := j to (i-1) do
                        if (t = 1) then P[k] := 2
                        else P[k] := 1;
                j := i;
                end;
        end;

min := 6000;
imin := 1;
for i := 1 to n do
        begin
        if (P[i] = 1) and (A[i] < min) then
                begin
                min := A[i];
                imin := i;
                end;
        end;

if (min = 6000) then
        begin
        for i := 1 to n do
                if (A[k] < min) then
                        begin
                        min := A[i];
                        imin := i;
                        end;
        writeln(g, '2');
        end
else writeln(g,'1');

S := R[imin, 1];
k := 0;
for i := 1 to n do
        begin
        if (A[i] = min) and (R[i,1] = S) then
                begin
                k := k + 1;
                for j := 1 to min do
                        RR[k,j] := R[i,j];
                end;
        end;

for jj := 2 to min do
        begin
        k := 1;
        S := RR[1,jj];
        while (RR[k,jj] = S) and (k < i+1) do
                k := k + 1;
        QSort(1,k-1,jj, RR);
        i := k-1;
        end;


for i := 1 to min do write(g, RR[1,i]);

close(f);
close(g);
end.

