#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;


const int ML = 100100;
int l, er;
string s[3];

int d[ML][3];
int c[ML];

bool can(int ner2[], int p) {
    int ner[3];
    for (int i = 0; i < 3; i++) {
        copy_n(ner2, 3, ner);
        for (int j = 0; j < 3; j++) {
            if (i == j) continue;
            ner[j] += c[p];
        }
        bool f = true;
        for (int j = 0; j < 3; j++) {
            if (er < ner[j]) {
                f = false;
                break;
            }
            int u = min(er - ner[j], d[p][j]);
            ner[j] += u;
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                ner[k] += d[p][j] - u;
            }
        }
        for (int j = 0; j < 3; j++) {
            if (er < ner[j]) {
                f = false;
                break;
            }
        }
        if (f) return true;
    }
    copy_n(ner2, 3, ner);
    for (int i = 0; i < 3; i++) {
        if (er < ner[i]) return false;
        ner[i] += d[p][i];
    }
//    int am = 0;
    int am[3];
    for (int i = 0; i < 3; i++) {
        if (er < ner[i]) return false;
        am[i] = er - ner[i];
    }
    sort(am, am+3, greater<int>());
    int cu;
    if (am[0] > am[1]+am[2]) {
        cu = am[1]+am[2];
    } else {
        cu = (am[0]+am[1]+am[2])/2;
    }
    if (cu < c[p]) return false;
    return true;
}

int ty(char a, char b, char c) {
    if (a == b && b == c) return -1;
    if (a == b) return 2;
    if (b == c) return 0;
    if (c == a) return 1;
    return 3;
}
bool solve() {
    scanf("%d %d", &l, &er);
    if (!l) return false;
    char buf[ML];
    for (int i = 0; i < 3; i++) {
        scanf("%s", buf);
        s[i] = buf;
    }

    int nd[3] = {}, nc = 0;
    copy_n(nd, 3, d[l]);
    c[l] = nc;
    for (int i = l-1; i >= 0; i--) {
        int u = ty(s[0][i], s[1][i], s[2][i]);
        if (u == -1) {
        } else if (u == 3) {
            nc++;
        } else {
            nd[u]++;
        }
        copy_n(nd, 3, d[i]);
        c[i] = nc;
//        printf("%d %d %d %d\n", d[i][0], d[i][1], d[i][2], c[i]);
    }

    string res = "";
    int ner[3] = {};
    for (int i = 0; i < l; i++) {
        char re = '$';
        for (char c = 'A'; c <= 'z'; c++) {
            if (!(('A' <= c && c <= 'Z') or ('a' <= c && c <= 'z'))) continue;
            for (int j = 0; j < 3; j++) {
                if (c != s[j][i]) {
                    ner[j]++;
                }
            }
            if (can(ner, i+1)) {
                re = c;
                break;
            }
            for (int j = 0; j < 3; j++) {
                if (c != s[j][i]) {
                    ner[j]--;
                }
            }
        }
        if (re == '$') {
            printf("-1\n");
            return true;
        }
        res += re;
    }
    printf("%s\n", res.c_str());
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}

Measured memory_bytes: 5200