/*
    Aleksandar "Al3kSaNdaR" Ivanovic

    igra
*/
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

const int MaxN = 5000 + 5;

int N;
bool Delete[MaxN];

string Words[MaxN];

inline bool Compare ( const string & First, const string & Second )
{
    int LenFirst = First.length ( ), LenSecond = Second.length ( );

    if ( LenFirst < LenSecond ) return true;
    if ( LenFirst > LenSecond ) return false;

    for ( int i = 0; i < LenFirst; i++ )
    {
        if ( First[i] < Second[i] ) return true;
        if ( First[i] > Second[i] ) return false;
    }

    return false;
}

int main ( void )
{
    scanf ( "%d", &N );

    for ( int i = 0; i < N; i++ ) cin >> Words[i];

    for ( int i = 0; i < N; i++ )
        for ( int j = i + 1; j < N; j++ ) if ( Compare ( Words[j], Words[i] ) ) swap ( Words[i], Words[j] );

    for ( int i = 0; i < N; i++ )
        for ( int j = i + 1; j < N; j++ ) if ( Words[j].substr ( 0, Words[i].length ( ) ) == Words[i] ) Delete[j] = true;

    int idx = 0;

    for ( int i = 0; i < N; i++ ) if ( ! Delete[i] ) Words[idx++] = Words[i];

    N = idx;

    for ( int i = 0; i < N; i++ ) if ( ! ( Words[i].length ( ) % 2 ) )
                                  {
                                      idx = i;

                                      break;
                                  }

    if ( idx == N )
    {
        cout << 2 << endl;

        cout << Words[0] << endl;

        return 0;
    }

    int Iter = 50;

    //Mirko - 0
    //Slavko - 1

    string Word;

    Word += Words[idx][0];

    int Player = 1;

    int LastminIdx = idx;

    while ( Iter-- )
    {
        idx = 0;

        int minIdx = -1;

        for ( int i = 0; i < N; i++ )
        {
            if ( ( minIdx == -1 ) && ( Words[i].substr ( 0, Word.length ( ) ) == Word ) ) minIdx = i;

            if ( ( Words[i].substr ( 0, Word.length ( ) ) == Word ) && ( Words[i].length ( ) % 2 == Player - 1 ) )
            {
                idx = i;

                break;
            }
        }


        if ( ( minIdx == -1 ) || ( idx == N ) )
        {
            cout << 2 - Player << endl;

            cout << Words[LastminIdx] << endl;

            return 0;
        }

        Word += Words[idx][Word.length ( )];

        Player ^= 1;

        LastminIdx = minIdx;
    }

    return 0;
}
