#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define LEN length()

const int MaxN = 5005;

int d[351][351][51], next[351][351][51];

int n;
string a[MaxN];
char s[MaxN];

FILE *ff = fopen("igra.in", "r");
FILE *gg = fopen("igra.out", "w");

bool cmp(string a, string b){
    return a < b;
}

int win(int i, int j, int len){
    //printf("i = %d j = %d len = %d\n", i, j, len);
    if (i == j) return a[i].LEN;

    int &ret = d[i][j][len];
    if (ret) return ret;

    int m = 55, M = 0;
    for (int k = i; k <= j; k++){
        int p = k;
        while (1){
            if (k == j) break;
            if (a[k][len] == a[k+1][len]) k++;
            else break;
        }

        int w;
        if (a[p].LEN == len) w = win(p+1, k, len+1);
        else w = win(p, k, len+1);

        if (w % 2 != len % 2) m = min(m, w);
        M = max(M, w);
    }

    if (m == 55)
        ret = M;
    else
        ret = m;
    return ret;
}

void Solve(){
    memset(d, 0, sizeof(0));
    int s = win(1, n, 1);
    /*for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j++){
            printf("i = %d j = %d\n   ", i, j);
            for (int k = 1; k <= 6; k++) printf("%d ", d[i][j][k]); printf("\n");
        }*/

    if (s % 2) fprintf(gg, "2\n");
    else fprintf(gg, "1\n");

    int i = 1; string sol;
    for (; i <= n; i++) if (a[i].LEN == s){
        sol = a[i]; break;
    }
    i++;
    for (; i <= n; i++) if (a[i] < sol) sol = a[i];
    fprintf(gg, "%s\n", sol.c_str());
}

int main(){
    fscanf(ff, "%d", &n);

    for (int i = 1; i <= n; i++){
        fscanf(ff, "%s", s);
        a[i].assign(s);
    }

    sort(a+1, a+n+1, cmp);

    //for (int i = 1; i <= n; i++) printf("%s\n", a[i].c_str());

    if (n <= 350){
        Solve();
        fclose(ff); fclose(gg);
        return 0;
    }

    if (a[1].LEN % 2) fprintf(gg, "2\n");
    else fprintf(gg, "1\n");
    fprintf(gg, "%s\n", a[1].c_str());

    fclose(ff); fclose(gg);
    return 0;
}
