import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;

string str[3];
char ans[100001];

bool check(int pair[], int dist, int dif[]) {
  int u[3];
  int sum = 0;
  for (int i=0; i<3; ++i) {
    u[i] = max(0,dist-(dif[i]-pair[i]));
    sum += u[i];
  }
  if (sum <= dist) return 1;
  for (int i=0; i<3; ++i) {
    int j = (i+1)%3;
    int k = (i+2)%3;
    if (u[j] == 0 && u[k] == 0) {
      int r = min(pair[i], min(dif[j]-pair[j]-dist, dif[k]-pair[k]-dist));
      if (sum - r <= dist) return 1;
    }
  }
  return 0;
}

void main() {
  string inp;
  while((inp = readln) != null) {
    string[] input = inp.split;
    int l = input[0].to!int;
    int d = input[1].to!int;
    if (l==0) break;    

    int pair[3];
    int dist;
    for (int i=0; i<3; ++i) {
      str[i] = readln.chomp;
    }
    for (int i=0; i<l; ++i) {
      char[] c = [str[0][i], str[1][i], str[2][i]];
      if (c[0]==c[1]&&c[1]==c[2]) {
      } else {
        bool ok = 0;
        for (int j=0; j<3; ++j) {
          if (c[(j+1)%3]==c[(j+2)%3]) {
            ok = 1;
            pair[j]++;
          }
        }
        if (!ok) {
          dist++;
        }
      }
    }

    bool ok = 0;
    int dif[3] = [d,d,d];
    for (int i=0; i<l; ++i) {
      char c[3] = [str[0][i],str[1][i],str[2][i]];
      char cand[4] = ['A',c[0],c[1],c[2]];
      cand.sort;
      
      if (c[0]==c[1]&&c[1]==c[2]) {
      } else {
        bool tok = 0;
        for (int j=0; j<3; ++j) {
          if (c[(j+1)%3]==c[(j+2)%3]) {
            tok = 1;
            pair[j]--;
          }
        }
        if (!tok) {
          dist--;
        }
      }

      ok = 0;
      for (int j=0; j<4; ++j) {
        for (int k=0; k<3; ++k) {
          if (c[k]!=cand[j]) {
            dif[k]--;
          }
        }

        if (check(pair,dist,dif)) {
          ans[i] = cand[j];
          ok = 1;
          break;
        }

        for (int k=0; k<3; ++k) {
          if (c[k]!=cand[j]) {
            dif[k]++;
          }
        }
        
      }
      if (!ok) break;
    }
    if (!ok) writeln(-1);
    else {
      ans[l] = 0;
      writeln(ans);
    }
  }
}