#include <bits/stdc++.h>
using namespace std;
struct iii {
  int a, b, c;
  iii() {}
  iii(int a, int b, int c) : a(a), b(b), c(c) {}
  bool operator<(const iii &e) const {
    return a < e.a || a == e.a && (b < e.b || b == e.b && c < e.c);
  }
};
template <typename T>
T sq(const T &x) {
  return x * x;
}
template <typename T>
void minl(T &a, const T &b) {
  if (a > b) a = b;
}
template <typename T>
void maxl(T &a, const T &b) {
  if (a < b) a = b;
}
template <typename T>
void operator+=(vector<T> &a, const T &x) {
  a.push_back(x);
}
template <typename T>
void operator+=(set<T> &a, const T &x) {
  a.insert(x);
}
template <typename T>
bool operator&(const set<T> &a, const T &x) {
  return a.find(x) != a.end();
}
template <typename A, typename B>
istream &operator>>(istream &i, pair<A, B> &v) {
  return i >> v.first >> v.second;
}
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>(a.first - b.first, a.second - b.second);
}
template <typename T>
void usort(vector<T> &a) {
  sort((a).begin(), (a).end());
  a.erase(unique((a).begin(), (a).end()), a.end());
}
template <typename T>
int index(const vector<T> &a, const T &x) {
  return lower_bound((a).begin(), (a).end(), x) - a.begin();
}
template <typename T>
T gcd(T a, T b) {
  while (b) {
    T t = a % b;
    a = b;
    b = t;
  }
  return a;
}
long long cross(const pair<int, int> &a, const pair<int, int> &b) {
  return (long long)a.first * b.second - (long long)b.first * a.second;
}
long long dot(const pair<int, int> &a, const pair<int, int> &b) {
  return (long long)a.first * b.first + (long long)a.second * b.second;
}
int bitcnt(unsigned x) { return __builtin_popcount(x); }
int bitlow(unsigned x) { return __builtin_ffs(x); }
const int N = 100;
const int C = 26;
int trans[N + 1][C];
int pf[N + 1];
void solo_auto(const string &s) {
  memset(trans, -1, sizeof(int) * (s.length() + 1) * C);
  for (int j = 0; j < C; j++) {
    trans[0][j] = 0;
  }
  for (int i = 0; i < s.length(); i++) {
    trans[i][s[i] - 'a'] = i + 1;
  }
  for (int i = 1; i <= s.length(); i++) {
    if (i == 1) {
      pf[i] = 0;
    } else {
      pf[i] = trans[pf[i - 1]][s[i - 1] - 'a'];
    }
    for (int j = 0; j < C; j++) {
      if (trans[i][j] == -1) {
        trans[i][j] = trans[pf[i]][j];
      }
    }
  }
}
void york() {
  int n, c;
  string p, mk;
  cin >> n >> c;
  cin >> p;
  cin >> mk;
  mk = string(((int)(p).size()) - 1, '0') + mk;
  solo_auto(p);
  int f[N + 1][N + 1];
  char ch[N + 1][N + 1];
  for (int i = 0; i < (n + 1); ++i) {
    for (int j = 0; j < (n + 1); ++j) {
      f[i][j] = -1;
    }
  }
  f[0][0] = -2;
  for (int i = 0; i < (n); ++i) {
    for (int j = (0); j <= (((int)(p).size())); ++j) {
      if (f[i][j] == -1) {
        continue;
      }
      for (int k = 0; k < (c); ++k) {
        int t = trans[j][k];
        if ((t == ((int)(p).size())) == (mk[i] == '1')) {
          f[i + 1][t] = j;
          ch[i + 1][t] = k;
        }
      }
    }
  }
  int t = -1;
  for (int i = 0; i < (n + 1); ++i) {
    if (f[n][i] != -1) {
      t = i;
      break;
    }
  }
  if (t == -1) {
    cout << "No solution";
    return;
  }
  string ans;
  for (int a = n; a > 0; a--) {
    ans += ch[a][t] + 'a';
    t = f[a][t];
  }
  reverse((ans).begin(), (ans).end());
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  york();
  return 0;
}
