#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <string.h>
using namespace std;

int length=0;
char solution[100];

inline int drugi(int i){
    return (i+1)%2;
}

class Trie{
  private:
    char symbol;
    bool kraj;
    int wins, d;
    Trie *next, *chd, *sol;
  public:
    Trie(){
        symbol=32;
        kraj=false; wins=0;
        next=NULL; chd=NULL; sol=NULL;
    }
    void insert(char *s){
        if (s[0]=='\0') {
            kraj=true;
            return;
        }
        Trie *p = chd;
        while (p!=NULL && p->symbol!=s[0]) p=p->next;
        if (p!=NULL) p->insert(s+1);
            else{
                p = new Trie();
                p->symbol=s[0];
                p->next=chd;
                chd=p;
                p->insert(s+1);
            }
    }
    int getWins(){
        return wins;
    }
    void pisi(char *s, int i){
        if (kraj){
            s[i]=symbol;
            s[i+1]='\0';
            printf("%s\n", s);
        }
        Trie *p = chd;
        while (p!=NULL){
            s[i]=symbol;
            p->pisi(s, i+1);
            p=p->next;
        }
    }
    void gen_win(int t){
        Trie *p = chd;
        if (kraj){
            wins=t;
            d=1; sol=0;
            return;
        }

        wins=drugi(t);
        while (p!=NULL) {
            p->gen_win(drugi(t));
            if (p->wins==t) wins=t;
            p=p->next;
        }

        p=chd;
        int s;
        if (wins==t){
            s=1000000;
            while (p!=NULL){
                if (p->wins==t && s>p->d){
                    s=p->d; sol=p;
                    d=s+1;
                }
                p=p->next;
            }
        } else{
            s=-1;
            while (p!=NULL){
                if (p->wins!=t && p->d>s){
                    s=p->d; sol=p;
                    d=s+1;
                }
                p=p->next;
            }
        }
    }
    void test(){
            Trie *p=chd;
            while (p!=NULL){
                printf("ako izabere %c onda pobedjuje %d\n", p->symbol, p->wins);
                p=p->next;
            }

    }
    ~Trie(){
        Trie *p=chd;
        Trie *t;
        while (p!=NULL){
            t=p; p=p->next;
            delete t;
        }
    }
    void pisi_sol(){
        if (symbol!=32) solution[length++]=symbol;
        if (sol!=NULL) sol->pisi_sol();
            else solution[length]='\0';
    }
};


int n;
char s[5005][55];
int ind[5005];

bool cmp(int a, int b){
    if (a==b) return 0;
    int i=0;
    while (s[a][i]==s[b][i]) i++;
    return s[a][i]>s[b][i];
}

void input(){
    FILE *f=fopen("igra.in", "r");
    fscanf(f, "%d", &n);
    for (int i=0; i<n; i++) {
        fscanf(f, "%s", s[i]);
        ind[i]=i;
    }
    fclose(f);
}

void solve(){
    sort(ind,ind+n,cmp);
    Trie t;
    for (int i=0; i<n; i++)
        t.insert(s[ind[i]]);

    t.gen_win(0);

    FILE *f=fopen("igra.out", "w");

    fprintf(f, "%d\n", t.getWins()+1);
    t.pisi_sol();
    fprintf(f, "%s\n", solution);
    fclose(f);
}

int main(){
    input();
    solve();

    return 0;
}
