#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

// xor128による乱数生成、周期は2^128-1
unsigned int randInt() {
    static unsigned int tx = 123456789, ty=362436069, tz=521288629, tw=88675123;
    unsigned int tt = (tx^(tx<<11));
    tx = ty; ty = tz; tz = tw;
    return ( tw=(tw^(tw>>19))^(tt^(tt>>8)) );
}

int randInt(int minv, int maxv) {
    return randInt() % (maxv - minv + 1) + minv;
}

// ランダムシャッフル
template<class T> void shuffle(vector<T>& vec) {
    int n = vec.size();
    for (int i = n - 1; i > 0; --i) {
        int k = randInt() % (i + 1);
        swap(vec[i], vec[k]);
    }
}

using CL = vector<pair<int,int> >;

bool rec(vector<int> &res, int k, const vector<CL> &cls) {
    if (k == cls.size()) return true;
    vector<pair<int,int> > rem;
    bool ok = false;
    for (int i = 0; i < cls[k].size(); ++i) {
        if (res[cls[k][i].first] == cls[k][i].second) {
            ok = true;
            break;
        }
        else if (res[cls[k][i].first] == -1) rem.push_back(cls[k][i]);
    }
    if (ok) return rec(res, k+1, cls);
    if (!ok && rem.empty()) return false;
    auto copy_res = res;
    for (int i = 0; i < rem.size(); ++i) {
        for (int j = 0; j < i; ++j) res[rem[j].first] = 1 - rem[j].second;
        res[rem[i].first] = rem[i].second;
        if (rec(res, k+1, cls)) return true;
    }
    res = copy_res;
    return false;
}

vector<int> solveSAT(int N, vector<CL> &cls) {
    for (int i = 0; i < (int)cls.size(); ++i) {
        map<int, set<int> > so;
        for (int j = 0; j < (int)cls[i].size(); ++j) {
            so[cls[i][j].first].insert(cls[i][j].second);
        }
        CL ncl;
        bool already = false;
        for (auto it : so) {
            if (it.second.size() == 2) already = true;
            ncl.push_back({it.first, *(it.second.begin())});
        }
        if (already) cls.erase(cls.begin() + i--);
        else cls[i] = ncl;
    }
    sort(cls.begin(), cls.end());
    for (int i = 0; i+1 < (int)cls.size(); ++i) {
        if (cls[i] == cls[i+1]) cls.erase(cls.begin() + i--);
    }
    vector<int> res(N, -1);
    if (rec(res, 0, cls)) return res;
    else return vector<int>();
}

int main() {
    int M;
    while (cin >> M, M) {
        vector<string> v(3);
        for (int i = 0; i < 3; ++i) cin >> v[i];
        
        vector<CL> cls;
        int iter = 0;
        for (int i = 0; i < M; ++i) {
            vector<int> pos({i*3+1, i*3+2});
            for (int bit = 0; bit < (1<<3); ++bit) {
                CL cl(3);
                for (int j = 0; j < 3; ++j) {
                    char c = (bit & (1<<j)) ? v[j][pos[1]] : v[j][pos[0]]; 
                    if (c >= 'a' && c <= 'z') cl[j] = {c - 'a', 1};
                    else cl[j] = {c - 'A', 0};
                }
                cls.push_back(cl);
            }
        }
        //shuffle(cls);

        //COUT(cls);
        
        auto res = solveSAT(26, cls);
        if (res.empty()) cout << -1 << endl;
        else {
            vector<char> ans;
            for (int i = 0; i < 26; ++i) {
                if (res[i] == 1) ans.push_back('A' + i);
            }
            cout << ans.size() << endl;
            for (auto c : ans) cout << c << endl;
        }
        
    }
}



Measured memory_bytes: 4204