// Arup Guha
// 3/7/2023
// Solution to 2022 SER D1/D2 Problem: Three Dice

using namespace std;

#include <iostream>
#include <string>

int n;
int masks[1000][3];

// Easier this way.
int perm[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};

void go();
int bitcnt(int n);
bool inconsistent(int idx);
bool solve(int* res, int k);
bool canDo(int* res, int pos, int myp);

int main() {

    // Store words as masks.
    cin >> n;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        for (int j=0; j<3; j++)
            masks[i][j] = (1<<(s[j]-'a'));
    }

    // Run it!
    go();

    return 0;
}

void go() {

    // Start by assigning based on first word.
    int res[3];
    for (int i=0; i<3; i++)
        res[i] = masks[0][i];

    // Run backtracker here.
    bool works = solve(res, 1);

    // Didn't work, oh well.
    if (!works) {
        cout << "0" << endl;
        return;
    }

    // Get all bits used, so calculate unused.
    int used = res[0] | res[1] | res[2];
    int notUsed = (1<<26)-1-used;
    int loc = 0;

    // Output result.
    for (int i=0; i<3; i++) {

        // First add bits until we get to 6.
        while (bitcnt(res[i]) < 6) {
            while ( (notUsed&(1<<loc)) == 0) loc++;
            res[i] |= (1<<loc);
            notUsed -= (1<<loc);
        }

        // Now output letters.
        for (int j=0; j<26; j++)
            if (res[i]&(1<<j)) cout << (char)('a'+j);

        // Between dice.
        if (i<2) cout << " ";
    }
    cout << endl;
}

// Returns the # of bits on in n, assumes 26 or fewer bits.
int bitcnt(int n) {
    int res = 0;
    for (int i=0; i<26; i++)
        if (n & (1<<i))
            res++;
    return res;
}

// Returns true iff entry idx is inconsistent (same letter 2 spots).
bool inconsistent(int idx) {
    for (int i=0; i<3; i++)
        for (int j=i+1; j<3; j++)
            if (masks[idx][i] == masks[idx][j])
                return true;
    return false;
}

// Returns true if there's a solution where dice have already been assigned
// based on res and have only assigned the first k words.
bool solve(int* res, int k) {

    // Mostly just catches case where first word has repeats.
    if (res[0]&res[1]) return false;
    if (res[0]&res[2]) return false;
    if (res[1]&res[2]) return false;

    // We did it.
    if (k == n) return true;

    // This word is inconsistent.
    if (inconsistent(k)) return false;

    // So we can reinstate things.
    int saver[3];
    for (int i=0; i<3; i++) saver[i] = res[i];

    // Try each permutation.
    for (int i=0; i<6; i++) {

        // This one isn't valid, skip it.
        if (!canDo(res, k, i)) continue;

        // Update dice with this setting for the word.
        for (int j=0; j<3; j++)
            res[j] |= masks[k][perm[i][j]];

        // Recurse, if it works return true.
        bool tmp = solve(res, k+1);
        if (tmp) return true;

        // Put back to old mask.
        for (int j=0; j<3; j++) res[j] = saver[j];
    }

    // Can't do it.
    return false;
}

// Returns true if we can use the word in index pos via permutation myp
// adding to res.
bool canDo(int* res, int pos, int myp) {

    // What our masks would be.
    int a = res[0] | masks[pos][perm[myp][0]];
    int b = res[1] | masks[pos][perm[myp][1]];
    int c = res[2] | masks[pos][perm[myp][2]];

    // This is not allowed; only 6 letter per die.
    if (bitcnt(a) > 6 || bitcnt(b)>6 || bitcnt(c)>6) return false;

    // Must be mutually exclusive...
    if (a&b) return false;
    if (a&c) return false;
    if (b&c) return false;
    return true;
}
