#include <bits/stdc++.h>
using namespace std;
struct Record {
  int pre;
  char ch;
};
int const N = 100;
int const M = 26;
int n, m;
char name[N + 10];
char des[N + 10];
int lname;
int ldes;
int fail[N + 10];
bool ok[N + 10][N + 10];
Record rec[N + 10][N + 10];
char res[N + 10];
bool readin() {
  if (scanf("%d%d", &n, &m) == EOF) return false;
  scanf("%s%s", name + 1, des + 1);
  lname = strlen(name + 1);
  ldes = strlen(des + 1);
  return true;
}
void kmp(char const *s, int l, int *prefix) {
  int i, j;
  prefix[1] = 0;
  for (i = 2; i <= l; ++i) {
    j = prefix[i - 1];
    while (j != 0) {
      if (s[j + 1] == s[i]) {
        prefix[i] = j + 1;
        break;
      }
      j = prefix[j];
    }
    if (j == 0) prefix[i] = s[i] == s[1] ? 1 : 0;
  }
}
bool dp() {
  int idx;
  int i, j, k;
  memset(ok, false, sizeof(ok));
  ok[0][0] = true;
  for (i = 0; i < n; ++i) {
    for (j = 0; j <= lname; ++j) {
      if (ok[i][j]) {
        for (k = 0; k < m; ++k) {
          idx = j < lname ? j : fail[j];
          while (idx != 0) {
            if ('a' + k == name[idx + 1]) {
              if (idx + 1 == lname) {
                if (des[i + 1 - lname + 1] == '1') {
                  ok[i + 1][idx + 1] = true;
                  rec[i + 1][idx + 1].pre = j;
                  rec[i + 1][idx + 1].ch = 'a' + k;
                }
              } else {
                if (i + 1 - lname + 1 < 1 || des[i + 1 - lname + 1] == '0') {
                  ok[i + 1][idx + 1] = true;
                  rec[i + 1][idx + 1].pre = j;
                  rec[i + 1][idx + 1].ch = 'a' + k;
                }
              }
              goto END;
            }
            idx = fail[idx];
          }
          if ('a' + k == name[1]) {
            if (1 == lname) {
              if (i + 1 - lname + 1 >= 1 && des[i + 1 - lname + 1] == '1') {
                ok[i + 1][1] = true;
                rec[i + 1][1].pre = j;
                rec[i + 1][1].ch = 'a' + k;
              }
            } else {
              if (i + 1 - lname + 1 < 1 || des[i + 1 - lname + 1] == '0') {
                ok[i + 1][1] = true;
                rec[i + 1][1].pre = j;
                rec[i + 1][1].ch = 'a' + k;
              }
            }
          } else {
            if (i + 1 - lname + 1 < 1 || des[i + 1 - lname + 1] == '0') {
              ok[i + 1][0] = true;
              rec[i + 1][0].pre = j;
              rec[i + 1][0].ch = 'a' + k;
            }
          }
        END:;
        }
      }
    }
  }
  for (i = 0; i <= lname; ++i) {
    if (ok[n][i]) {
      k = i;
      for (j = n; j >= 1; --j) {
        res[j] = rec[j][k].ch;
        k = rec[j][k].pre;
      }
      return true;
    }
  }
  return false;
}
void solve() {
  kmp(name, lname, fail);
  printf("%s\n", dp() ? res + 1 : "No solution");
}
int main() {
  while (readin()) solve();
  return 0;
}
