#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int n;
char str[5005][55];

struct Node {
    Node * g[26];
    int end;
    int mark;

    int idx;
    int win;
    int moves;

    Node() {
        for (int i = 0; i < 26; ++i)
            g[i] = NULL;
        end = -1;
        mark = 0;
    }
} *root;

void insert(Node *at, int a, const int sz, const int idx) {
    if (a == sz) {
        at->end = idx;
        return;
    }
    if (at->g[str[idx][a] - 'a'] == NULL)
        at->g[str[idx][a] - 'a'] = new Node();
    insert(at->g[str[idx][a] - 'a'], a + 1, sz, idx);
}

int better(Node *a, Node *b) {
    if (a->win == 0 && b->win == 0) return 1;
    if (a->win == 1 && b->win == 1) return 0;
    if (a->win == 1 && b->win == 0) {
        if (a->moves > b->moves + 1) return 1;
        return 0;
    }
    if (a->win == 0 && b->win == 1) {
        if (a->moves < b->moves + 1) return 1;
        return 0;
    }
}

void solve(Node *node) {
    if (node->mark) return;
    node->mark = true;
    node->win = 0;
    node->moves = -1;
    if (node->end != -1) {
        node->moves = 0;
        node->idx = node->end;
    } else {
        for (int i = 0; i < 26; ++i) {
            if (node->g[i] == NULL) continue;
            solve(node->g[i]);
            if (better(node, node->g[i])) {
                node->win = 1 - node->g[i]->win;
                node->moves = node->g[i]->moves + 1;
                node->idx = node->g[i]->idx;
            }
        }
    }
}

int main() {
    freopen("igra.in", "r", stdin);
    freopen("igra.out", "w", stdout);
    root = new Node();
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%s", &str[i]);
        int sz = strlen(str[i]);
        insert(root, 0, sz, i);
    }
    solve(root);
    Node *sol = NULL;
    int best = -1;
    for (int i = 0; i < 26; ++i) {
        if (root->g[i] == NULL) continue;
        if (sol == NULL) sol = root->g[i];
        else {
            Node *cur = root->g[i];
            if (sol->win == 0 && cur->win == 1) sol = cur;
            else if (sol->win == 1 && cur->win == 0) {
            } else if (sol->win == 0 && cur->win == 0) {
                if (sol->moves < cur->moves) sol = cur;
            } else {
                if (sol->moves > cur->moves) sol = cur;
            }
        }
    }
    if (sol->win == 1) printf("1\n");
    else printf("2\n");
    printf("%s\n", str[sol->idx]);
    return 0;
}
