Problem: Problem Statement

You bought 3 ancient scrolls from a magician. These scrolls have a long string, and the lengths of the strings are the same. He said that these scrolls are copies of the key string to enter a dungeon with a secret treasure. However, he also said, they were copied so many times by hand, so the string will contain some errors, though the length seems correct.

Your job is to recover the original string from these strings. When finding the original string, you decided to use the following assumption.

* The copied string will contain at most d errors. In other words, the Hamming distance of the original string and the copied string is at most d.
* If there exist many candidates, the lexicographically minimum string is the original string.



Can you find the orignal string?



Input

The input contains a series of datasets.

Each dataset has the following format:


l d
str_1
str_2
str_3


The first line contains two integers l (1 \leq l \leq 100,000) and d (0 \leq d \leq 5,000.) l describes the length of 3 given strings and d describes acceptable maximal Hamming distance. The following 3 lines have given strings, whose lengths are l. These 3 strings consist of only lower and upper case alphabets.

The input ends with a line containing two zeros, which should not be processed.

Output

Print the lexicographically minimum satisfying the condition in a line. If there do not exist such strings, print `-1`.

Example

Input

3 1
ACM
IBM
ICM
5 2
iwzwz
iziwi
zwizi
1 0
A
B
C
10 5
jLRNlNyGWx
yyLnlyyGDA
yLRnvyyGDA
0 0


Output

ICM
iwiwi
-1
AARAlNyGDA

Solution (in CPP):

Solution:
#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;
}