#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0), eps = 1e-8;
const int inf = ~0U >> 2;
int mod = 1e9 + 7;
int Pow(int x, long long t) {
  int r = 1;
  for (; t; t >>= 1, x = (long long)x * x % mod)
    if (t & 1) r = (long long)r * x % mod;
  return r;
}
const int N = 1010;
int n, K, len1, len2;
char s[N], t[N];
char ans[N];
int ne[N];
bool same(char *s, char *t, int len) {
  for (int i = 0; i < len; ++i)
    if (s[i] != t[i]) return false;
  return true;
}
bool ok() {
  for (int i = 0; i < len2; ++i)
    if (t[i] == '1') {
      for (int j = i; j < i + len1; ++j) {
        if (ans[j] && ans[j] != s[j - i]) return false;
        ans[j] = s[j - i];
      }
    }
  for (int i = 0; i < len2; ++i)
    if (t[i] == '0' && same(ans + i, s, len1)) return false;
  ne[0] = -1;
  for (int i = 1, j = -1; i < len1; ++i) {
    if (s[i] == s[j + 1])
      ++j;
    else
      while (~j && s[i] != s[j + 1]) j = ne[j];
    ne[i] = j;
  }
  for (int i = 0, j = -1; i < n; ++i) {
    if (!ans[i]) ans[i] = s[j + 1] == 'a' ? 'b' : 'a';
    if (ans[i] == s[j + 1])
      ++j;
    else
      while (~j && ans[i] != s[j + 1]) j = ne[j];
    if (j == len1 - 1) j = ne[j];
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &K);
  scanf("%s", s);
  scanf("%s", t);
  len1 = strlen(s), len2 = strlen(t);
  if (ok()) {
    for (int i = 0; i < n; ++i) printf("%c", ans[i]);
    puts("");
  } else
    puts("No solution");
  return 0;
}
