#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

[[noreturn]] void die() {
    std::cout << 0 << '\n';
    std::exit(0);
}

struct Solver {
    Solver(std::vector<std::string> words): words_(words), dice_{0, 0, 0}, sides_{0, 0, 0}, totalMask_{0} {
    }

    bool solve(size_t wordIdx) {
        if (wordIdx == words_.size()) {
            return true;
        }

        const std::string& word = words_[wordIdx];
        std::array<uint32_t, 3> p{0, 1, 2};
        std::array<uint32_t, 3> toRemove;
        uint32_t numRemove = 0;
        do {
            numRemove = 0;
            bool canPlace = true;
            for (auto i = 0; i < 3; ++i) {
                uint32_t idx = word[i] - 'a';
                if (dice_[p[i]] >> idx & 1) {
                    // pass
                } else if (sides_[p[i]] < 6 && (totalMask_ >> idx & 1) == 0) {
                    toRemove[numRemove++] = i;
                    totalMask_ |= (1u << idx);
                    dice_[p[i]] |= (1u << idx);
                    ++sides_[p[i]];
                } else {
                    canPlace = false;
                    break;
                }
            }

            if (canPlace && solve(wordIdx + 1)) {
                return true;
            }

            for (auto j = 0; j < numRemove; ++j) {
                auto i = toRemove[j];
                uint32_t idx = word[i] - 'a';
                totalMask_ &= ~(1u << idx);
                dice_[p[i]] &= ~(1u << idx);
                --sides_[p[i]];
            }
        } while (std::next_permutation(p.begin(), p.end()));

        return false;
    }

    std::vector<std::string> words_;
    std::array<uint32_t, 3> dice_;
    std::array<uint32_t, 3> sides_;
    uint32_t totalMask_;
};

int main() {
    int32_t n;
    std::cin >> n;

    std::vector<std::string> words;
    {
        std::string word;
        for (auto i = 0; i < n; ++i) {
            std::cin >> word;
            words.push_back(std::move(word));
        }
    }

    Solver solver(std::move(words));
    if (solver.solve(0)) {
        for (auto mask : solver.dice_) {
            std::string die;
            for (auto i = 0u; i < 26; ++i) {
                if (mask >> i & 1) {
                    die.push_back('a' + i);
                }
            }

            for (auto i = die.size(); i < 6; ++i) {
                for (auto j = 0u; j < 26; ++j) {
                    if (!(solver.totalMask_ >> j & 1)) {
                        solver.totalMask_ |= (1u << j);
                        die.push_back('a' + j);
                        break;
                    }
                }
            }

            std::cout << die << ' ';
        }
        std::cout << '\n';
    } else {
        std::cout << 0 << '\n';
    }

    return 0;
}
