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 JAVA):

Solution:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	final int maxn = 101001;

	int l, d;
	String[] str = new String[3];
	char[] ans = new char[maxn];
	int[][] sum = new int[maxn][4];
	int[][] val = new int[maxn][3];

	boolean check(int idx, int valA, int valB, int valC) {
		int vala = sum[idx][0];
		int valb = sum[idx][1];
		int valc = sum[idx][2];
		int vald = sum[idx][3];
		if (d - valA < 0)
			return false;
		if (d - valB < 0)
			return false;
		if (d - valC < 0)
			return false;
		if (vala + valA > d) {
			valb += vala + valA - d;
			valc += vala + valA - d;
			vala = d - valA;
		}
		if (valb + valB > d) {
			vala += valb + valB - d;
			valc += valb + valB - d;
			valb = d - valB;
		}
		if (valc + valC > d) {
			vala += valc + valC - d;
			valb += valc + valC - d;
			valc = d - valC;
		}
		if (vala + valA > d || valb + valB > d)
			return false;
		int tmpA = Math.min(vald, d - vala - valA);
		int tmpB = Math.min(vald, d - valb - valB);
		int tmpC = Math.min(vald, d - valc - valC);
		if (tmpA + tmpB + tmpC < vald * 2)
			return false;
		return true;
	}

	void run() {

		Scanner scan = new Scanner(System.in);

		while (scan.hasNext()) {
			l = scan.nextInt();
			d = scan.nextInt();
			if (l == 0 && d == 0)
				break;
			for (int i = 0; i < 3; i++) {
				str[i] = scan.next();
			}
			for (int i = 0; i < maxn; i++)
				for (int j = 0; j < 4; j++)
					sum[i][j] = 0;
			for (int i = l - 1; i >= 0; i--) {
				for (int j = 0; j <= 3; j++) {
					sum[i][j] = sum[i + 1][j];
				}
				if (str[0].charAt(i) == str[1].charAt(i)
						&& str[1].charAt(i) == str[2].charAt(i))
					continue;
				if (str[0].charAt(i) == str[1].charAt(i))
					sum[i][2]++;
				else if (str[0].charAt(i) == str[2].charAt(i))
					sum[i][1]++;
				else if (str[1].charAt(i) == str[2].charAt(i))
					sum[i][0]++;
				else
					sum[i][3]++;
			}
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < l; j++) {
					if (str[i].charAt(j) >= 'A' && str[i].charAt(j) <= 'Z') {
						val[j][i] = (int) (str[i].charAt(j) - 'A');
					} else {
						val[j][i] = (int) (str[i].charAt(j) - 'a' + 26);
					}
				}
			}
			if (check(0, 0, 0, 0) == false) {
				System.out.println("-1");
				continue;
			}

			int valA = 0, valB = 0, valC = 0;
			int ansA = 0, ansB = 0, ansC = 0;
			for (int i = 0; i < l; i++) {
				for (int j = 0; j < 52; j++) {
					int tmpA = 0, tmpB = 0, tmpC = 0;
					if (j != val[i][0])
						tmpA = 1;
					if (j != val[i][1])
						tmpB = 1;
					if (j != val[i][2])
						tmpC = 1;
					valA = ansA + tmpA;
					valB = ansB + tmpB;
					valC = ansC + tmpC;
					if (check(i + 1, valA, valB, valC) == true) {
						if (j < 26) {
							ans[i] = (char) ('A' + j);
						} else {
							ans[i] = (char) ('a' + j - 26);
						}
						// System.out.println("HEHE " + i);
						ansA = valA;
						ansB = valB;
						ansC = valC;
						break;
					}
				}
				// System.out.println("HEHE " + i);
			}
			for (int i = 0; i < l; i++) {
				System.out.print(ans[i]);
			}
			System.out.println();
		}

	}

	public static void main(String arsgs[]) {
		new Main().run();
	}
}