#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const int maxk = 26;
struct node {
  int next[maxk], flag, fail;
} tree[maxn];
char s[maxn], t[maxn];
int f[maxn][maxn], p[maxn][maxn], letter[maxn][maxn], v[maxn], n, m, root, size;
int ans[maxn];
void insert(char *s) {
  int len = strlen(s), x = root;
  for (int i = 0; i < len; ++i) {
    int idx = s[i] - 'a';
    if (!tree[x].next[idx]) tree[x].next[idx] = ++size;
    x = tree[x].next[idx];
  }
  tree[x].flag = 1;
}
void build() {
  queue<int> que;
  que.push(root);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = 0; i < m; ++i) {
      if (tree[x].next[i]) {
        if (x == root)
          tree[tree[x].next[i]].fail = root;
        else
          tree[tree[x].next[i]].fail = tree[tree[x].fail].next[i];
        que.push(tree[x].next[i]);
      } else {
        if (x == root)
          tree[x].next[i] = root;
        else
          tree[x].next[i] = tree[tree[x].fail].next[i];
      }
    }
  }
}
void init() {
  scanf("%d%d", &n, &m);
  root = size = 1;
  scanf("%s%s", s, t);
}
void work() {
  insert(s);
  build();
  memset(f, 0, sizeof(f));
  int len = strlen(t), l = strlen(s);
  for (int i = 0; i < len; ++i) v[i + l] = t[i] - '0';
  f[0][root] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= size; ++j) {
      if (!f[i][j]) continue;
      for (int h = 0; h < m; ++h) {
        int tx = tree[j].next[h];
        if (v[i + 1] != tree[tx].flag) continue;
        f[i + 1][tx] = 1;
        p[i + 1][tx] = j;
        letter[i + 1][tx] = h;
      }
    }
  }
  int x = n, y = 0;
  for (int i = 1; i <= size && !y; ++i) {
    if (!f[n][i]) continue;
    y = i;
  }
  if (!y)
    puts("No solution");
  else {
    while (x) {
      ans[++ans[0]] = letter[x][y];
      y = p[x][y];
      --x;
    }
    for (int i = n; i; --i) printf("%c", 'a' + ans[i]);
    puts("");
  }
}
int main() {
  init();
  work();
  return 0;
}
