#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n, k;
int m;
string ans = "";
int p[101];
int was[101][102];
int g[101][26];
string w, s;
int go(int i, int j) {
  if (i == n) return 1;
  if (was[i][j + 1]) return 0;
  was[i][j + 1] = 1;
  for (int c = 0; c < m; c++) {
    int nj = g[j + 1][c];
    if (nj == k - 1 && w[i] == '1' && go(i + 1, p[k - 1])) {
      ans = ans + char(c + 'a');
      return 1;
    }
    if (nj != k - 1 && w[i] == '0' && go(i + 1, nj)) {
      ans = ans + char(c + 'a');
      return 1;
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  cin >> s;
  cin >> w;
  p[0] = -1;
  k = ((int)(s).size());
  while (((int)(w).size()) < n) w = "0" + w;
  for (int i = 1; i < k; i++) {
    int t = p[i - 1];
    while (t != -1 && s[t + 1] != s[i]) t = p[t];
    if (s[t + 1] == s[i]) t++;
    p[i] = t;
  }
  for (int i = -1; i + 1 < k; i++)
    for (int c = 0; c < m; c++) {
      int t = i;
      while (t != -1 && s[t + 1] != c + 'a') t = p[t];
      if (s[t + 1] == c + 'a') t++;
      g[i + 1][c] = t;
    }
  if (go(0, -1)) {
    reverse((ans).begin(), (ans).end());
    cout << ans << endl;
  } else
    cout << "No solution" << endl;
  return 0;
}
