#include <bits/stdc++.h>
using namespace std;
string valid, str;
char out[102];
int n, K, tab[102][26];
bool vis[102][102];
bool solve(int k, int match) {
  int sz = str.size();
  if (match == sz && valid[k - sz] == '0') return false;
  if (match < sz && k >= sz && valid[k - sz] == '1') return false;
  if (k == n) return true;
  if (vis[k][match]) return false;
  vis[k][match] = true;
  for (int i = 0; i < K; i++) {
    out[k] = 'a' + i;
    if (solve(k + 1, tab[match][i])) return true;
  }
  return false;
}
int main() {
  cin >> n >> K;
  cin >> str >> valid;
  int sz = str.size();
  for (int i = 0; i <= sz; i++)
    for (int j = 0; j < K; j++) {
      string have = str.substr(0, i);
      have += (char)('a' + j);
      for (int k = min(sz, i + 1); k >= 0; k--)
        if (have.substr(i + 1 - k) == str.substr(0, k)) {
          tab[i][j] = k;
          break;
        }
    }
  bool ret = solve(0, 0);
  if (!ret)
    cout << "No solution" << endl;
  else
    cout << out << endl;
  return 0;
}
