import java.util.Scanner;

public class threedice_da {

    private boolean[][] g;

    private void work() {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        g = new boolean[256][256];
        boolean[] used = new boolean[256];
        char[] all = new char[18];
        int cnt = 0;
        boolean ok = true;
        while (n-- > 0) {
            char[] s = sc.next().toCharArray();
            if (s[0] == s[1] || s[1] == s[2] || s[0] == s[2]) ok = false;
            if (ok) {
                for (int i = 0; i < 3; i++) {
                    if (!used[s[i]]) {
                        if (cnt == 18) {
                            ok = false;
                            break;
                        }

                        used[s[i]] = true;
                        all[cnt++] = s[i];
                    }

                    for (int j = 0; j < 3; j++) {
                        g[s[i]][s[j]] = g[s[j]][s[i]] = true;
                    }
                }
            }
        }

        if (!ok) {
            System.out.println(0);
            System.exit(0);
        }

        for (char c = 'a'; c <= 'z' && cnt < 18; c++) {
            if (!used[c]) {
                all[cnt++] = c;
            }
        }

        // for each valid first die, see if we can split the remaining 12 into two
        char[] two = new char[12];
        int mask18 = (1 << 6) - 1;
        int lim = 1 << 18;
        int lim2 = 1 << 12;
        ok = false;
        while (mask18 < lim) {
            if (isValid(mask18, all)) {
                int k = 0;
                for (int i = 0; i < 18; i++) {
                    if (((1 << i) & mask18) == 0) two[k++] = all[i];
                }

                int mask12 = (1 << 6) - 1;
                while (mask12 < lim2) {
                    if (isValid(mask12, two) && isValid(~mask12 & (lim2 - 1), two)) {
                        ok = true;
                        break;
                    }
                    mask12 = snoob(mask12);
                }

                if (ok) {
                    // x&all, y&two, ~y&two
                    for (int i = 0; i < 18; i++) {
                        if (((1 << i) & mask18) != 0) {
                            System.out.write(all[i]);
                        }
                    }
                    System.out.write(' ');
                    for (int i = 0; i < 12; i++) {
                        if (((1 << i) & mask12) != 0) {
                            System.out.write(two[i]);
                        }
                    }
                    System.out.write(' ');
                    for (int i = 0; i < 12; i++) {
                        if (((1 << i) & mask12) == 0) {
                            System.out.write(two[i]);
                        }
                    }
                    System.out.println();
                    break;
                }
            }

            mask18 = snoob(mask18);
        }

        if (!ok) {
            System.out.println(0);
        }
    }

    private char[] cs = new char[6];
    private boolean isValid(int mask, char[] a) {
        int n = a.length;
        int k = 0;
        for (int i = 0; i < n; i++) {
            if (((1 << i) & mask) != 0) cs[k++] = a[i];
        }

        return isValid();
    }

    private boolean isValid() {
        for (int i = 0; i < 6; i++) {
            for (int j = i + 1; j < 6; j++) {
                if (g[cs[i]][cs[j]]) {
                    return false;
                }
            }
        }
        return true;
    }

    private int snoob(int x) {
        int smallest, ripple, ones;
        smallest = x & -x;
        ripple = x + smallest;
        ones = x ^ ripple;
        ones = (ones >>> 2) / smallest;
        x = ripple | ones;
        return x;
    }

    public static void main(String[] args) {
        new threedice_da().work();
    }
}
