#include <bits/stdc++.h>
using namespace std;
char s[1100], s2[1100];
int dp[110][110];
string ans[110][110];
int g[110][110];
int main() {
  int n, K, len;
  while (scanf("%d%d", &n, &K) == 2) {
    scanf("%s", s);
    int len = strlen(s);
    string tans = "";
    for (int i = 0; i <= len; i++) {
      for (int k = 0; k < K; k++) {
        string next = tans;
        next.push_back(k + 'a');
        int anss = 0;
        int tlen = next.size();
        for (int ii = 0; ii < tlen; ii++) {
          int tnum = 0;
          for (int jj = ii; jj < tlen; jj++) {
            if (s[jj - ii] != next[jj]) break;
            tnum++;
          }
          if (tnum == tlen - ii) anss = max(anss, tnum);
        }
        g[i][k] = anss;
      }
      tans += s[i];
    }
    scanf("%s", s2);
    memset(dp, 0, sizeof(dp));
    int len2 = strlen(s2);
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < len; j++) ans[i][j] = "";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= len; j++) {
        if (dp[i][j] == 0) continue;
        if (dp[i][j]) {
        }
        if (i - len >= 0) {
          if (s2[i - len] == '1' && j != len) continue;
          if (s2[i - len] == '0' && j == len) continue;
        }
        string temp = "";
        int begin = max(0, i - j + 1);
        for (int k = begin; k < i; k++) temp += ans[i][j][k];
        for (int k = 0; k < K; k++) {
          string next = temp;
          next.push_back(k + 'a');
          int num = g[j][k];
          if (dp[i + 1][num] == 0) {
            dp[i + 1][num] = 1;
            ans[i + 1][num] = ans[i][j];
            ans[i + 1][num].push_back(k + 'a');
          }
        }
      }
    }
    if (s2[len2 - 1] == '1') {
      if (dp[n][len] == 0)
        puts("No solution");
      else
        printf("%s\n", ans[n][len].c_str());
    } else {
      bool find = false;
      for (int i = 0; i < len; i++)
        if (dp[n][i]) {
          find = true;
          printf("%s\n", ans[n][i].c_str());
          break;
        }
      if (!find) puts("No solution");
    }
  }
  return 0;
}
