	import java.io.*;
import java.math.*;
import java.nio.file.attribute.AclEntry.Builder;
import java.security.KeyStore.Entry;
import java.util.*;

	public  class Khatri {
		private InputStream is;
		private PrintWriter out;
		int time = 0, val[][], dp[][], DP[], start[], end[], dist[],  black[], MOD = (int)(1e9+7), arr[], weight[][], x[], y[], parent[];
		int MAX = 800000, N, K, L;
		long red[];
		ArrayList<Integer>[] amp;
		//boolean b[], boo[][];
		Pair prr[];
		HashSet<Integer> hs = new HashSet<>();
		long Dp[][][][] = new long[110][110][12][12];

		public static void main(String[] args) throws Exception {
			new Thread(null, new Runnable() {
			public void run() {
				try {

			//new CODEFORCES().soln();
			} catch (Exception e) {
					System.out.println(e);
				}
			}
		}, "1", 1 << 26).start();
			new Khatri().soln();
		}
		char ch[][];
		int ans = 0, cnt = 0, Q;
		int n1, n2, k1, k2, M;
		static int a[]=new int[100005];		static int b[]=new int[100005];
		void solve() {
			int n=ni();
			int k=ni();
			String s=ns();
			boolean bl[]=new boolean[26];
			for(int i=0;i<s.length();i++)
				bl[s.charAt(i)-'a']=true;
			int count=0;
			char tmp='-';
			for(char c='a';c<='z';c++)
			{
				if(count<k)
				{
					if(!bl[c-'a'])
					{
					tmp=c;
					break;
					}
				}
				count++;
			}
			String p=ns();
			char ans[]=new char[n];
			Arrays.fill(ans,'-');
			for(int i=0;i<p.length();i++)
			{
				if(p.charAt(i)=='1')
				{
					int curr=i;
					for(int j=0;j<s.length();j++)
					{
						if(ans[curr]!='-'&&ans[curr]!=s.charAt(j))
						{
							out.println("No solution");
							return;
						}
						ans[curr++]=s.charAt(j);
					}
				}
			}
			if(tmp=='-')
				tmp='b';
			for(int i=0;i<n;i++)
				if(ans[i]=='-')
					ans[i]=tmp;
			for(int i=0;i<n-s.length()+1;i++)
			{
				int cp=0;int curr=i;
                for(int j=0;j<s.length();j++)
                {
                	if(s.charAt(j)==ans[curr])
                	{
                		cp++;
                	}
                	curr++;
                }
                if(curr==s.length())
                {
                	out.print("No solution");
                	return;
                }
			}
			out.println(new String(ans));
		}
		boolean isPrime(int x){
			for(int i = 2;i*1L*i<=x;i++) if(x%i==0) return false;
			return true;
		}
	    int  p ;
		void buildGraph(int n)
		{
			for(int i = 0; i<n ;i++){
				int x1 = ni() -1, y1 = ni()-1;
				amp[x1].add(y1);
				amp[y1].add(x1);
				x[i] = x1; y[i] = y1;
			}
		}
		long get(int x){
			long val = 0;
			for(int i = 0; i< N; i++){
				val += Math.abs(x-arr[i]);
				x+=L;
			}
			return val;
		}

		long modInverse(long a, long mOD2){
	        return  power(a, mOD2-2, mOD2);
		}
		long power(long x, long y, long m)
		{
			if (y == 0)
	    return 1;
		long p = power(x, y/2, m) % m;
		p = (p * p) % m;

		return (y%2 == 0)? p : (x * p) % m;
		}

		public long gcd(long a, long b){
			if(b==0) return a;
			return gcd(b,a%b);
		}

		public static int[] shuffle(int[] a, Random gen){
			for(int i = 0, n = a.length;i < n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int d = a[i];
				a[i] = a[ind];
				a[ind] = d;
			}
		return a;
		}

		class Pair implements Comparable<Pair>{
			int u, v, i;
			Pair(int u, int v){
				this.u = u;
				this.v = v;
			}
			Pair(int u, int v, int i){
				this.u = u;
				this.v = v;
				this.i = i;
			}
			public int hashCode() {
				return Objects.hash();
			}
			/*public boolean equals(Object o) {
				Pair other = (Pair) o;
				return ((u == other.u && v == other.v) || (v == other.u && u == other.v));
			}*/
			public int compareTo(Pair other) {
				//return Integer.compare(val, other.val);
				return Long.compare(u, other.u) != 0 ? (Long.compare(u, other.u)) : (Long.compare(v,other.v));
			}
			public String toString(){
				return this.u +" " + this.v;
			}
		}
		long power(long x, long y, int mod){
			long ans = 1;
			while(y>0){
				if(y%2==0){
					x = (x*x)%mod;
					y/=2;
				}
				else{
					ans = (x*ans)%mod;
					y--;
				}
			}
			return ans;
		}
		void soln() {
			is = System.in;
			out = new PrintWriter(System.out);
			long s = System.currentTimeMillis();
			solve();
			//out.close();
			out.flush();
			//tr(System.currentTimeMillis() - s + "ms");
		}

		// To Get Input
		// Some Buffer Methods
		private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		private int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		private double nd() {
			return Double.parseDouble(ns());
		}

		private char nc() {
			return (char) skip();
		}
		private String ns() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
										// ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		private char[] ns(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		private char[][] nm(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}

		private int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = ni();
			return a;
		}

		private int ni() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private long nl() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

		private void tr(Object... o) {
			if (!oj)
				System.out.println(Arrays.deepToString(o));
		}
	}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

public class Main implements Runnable {
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintStream out;

	char[] w, p;
	int n, k, l, stand = 0;

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	void fill(int i) {
		for (int pos = i; pos < i + l; pos++) {
			if (w[pos] != '*' && w[pos] != p[pos - i]) {
				out.println("No solution");
				System.exit(0);
			}
			w[pos] = p[pos - i];
		}
	}

	boolean canbe(char [] cc, int i) {
		for (int pos = i; pos < i + l; pos++) {
			if (cc[pos] != '*' && cc[pos] != p[pos - i]) {
				return false;
			}
		}
		return true;
	}

	boolean[] can(char [] cc) {
		boolean[] ret = new boolean[n - l + 1];
		for (int i = 0; i <= n - l; i++) {
			ret[i] = canbe(cc, i);
		}
		return ret;
	}

	int done(char [] cc) {
		boolean [] q = can(cc);
		int ans = 0;
		for (int i = 0; i <= n - l; i++) {
			if (!q[i]) ans++;
		}
		return ans;
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(System.out);

			n = nextInt();
			k = nextInt();
			w = new char[n];
			Arrays.fill(w, '*');

			p = nextToken().toCharArray();
			l = p.length;
			char[] pos = nextToken().toCharArray();
			for (int i = 0; i < n - l + 1; i++) {
				if (pos[i] == '1') {
					stand++;
					fill(i);
				}
			}

			boolean[] used = new boolean[k];
			for (int i = 0; i < l; i++) {
				used[p[i] - 'a'] = true;
			}
			for (int i = 0; i < k; i++) {
				if (!used[i]) {
					for (int j = 0; j < n; j++) {
						if (w[j] == '*')
							out.print((char) (i + 'a'));
						else
							out.print(w[j]);
					}
					out.println();
					System.exit(0);
				}
			}

			char[] wg = new char[n];
			for (int i = 0; i < n; i++) {
				wg[i] = w[i];
			}

			for (int i = 0; i < n; i++) {
				if (wg[i] == '*') {
					int bd = -1;
					char bc = 'X';
					for (char c = 'a'; c < 'a' + k; c++) {
						wg[i] = c;
						int d = done(wg);
						if (d > bd) {
							bd = d;
							bc = c;
						}
					}
					wg[i] = bc;
				}
			}
			if (done(wg) == n - l + 1 - stand) {
				out.println(wg);
				System.exit(0);
			}

			out.println("No solution");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

public class Main implements Runnable {
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintStream out;

	char[] w, p;
	int n, k, l, stand = 0;

	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	void fill(int i) {
		for (int pos = i; pos < i + l; pos++) {
			if (w[pos] != '*' && w[pos] != p[pos - i]) {
				out.println("No solution");
				System.exit(0);
			}
			w[pos] = p[pos - i];
		}
	}

	boolean canbe(char [] cc, int i) {
		for (int pos = i; pos < i + l; pos++) {
			if (cc[pos] != '*' && cc[pos] != p[pos - i]) {
				return false;
			}
		}
		return true;
	}

	boolean[] can(char [] cc) {
		boolean[] ret = new boolean[n - l + 1];
		for (int i = 0; i <= n - l; i++) {
			ret[i] = canbe(cc, i);
		}
		return ret;
	}

	int done(char [] cc) {
		boolean [] q = can(cc);
		int ans = 0;
		for (int i = 0; i <= n - l; i++) {
			if (!q[i]) ans++;
		}
		return ans;
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(System.out);

			n = nextInt();
			k = nextInt();
			w = new char[n];
			Arrays.fill(w, '*');

			p = nextToken().toCharArray();
			l = p.length;
			char[] pos = nextToken().toCharArray();
			for (int i = 0; i < n - l + 1; i++) {
				if (pos[i] == '1') {
					stand++;
					fill(i);
				}
			}

			boolean[] used = new boolean[k];
			for (int i = 0; i < l; i++) {
				used[p[i] - 'a'] = true;
			}

			/*for (int i = 0; i < k; i++) {
				if (!used[i]) {
					for (int j = 0; j < n; j++) {
						if (w[j] == '*')
							out.print((char) (i + 'a'));
						else
							out.print(w[j]);
					}
					out.println();
					System.exit(0);
				}
			}*/

			char[] wg = new char[n];
			for (int i = 0; i < n; i++) {
				wg[i] = w[i];
			}

			for (int i = 0; i < n; i++) {
				if (wg[i] == '*') {
					int bd = -1;
					char bc = 'X';
					for (char c = 'a'; c < 'a' + k; c++) {
						wg[i] = c;
						int d = done(wg);
						if (d > bd) {
							bd = d;
							bc = c;
						}
					}
					wg[i] = bc;
				}
			}

			if (done(wg) == n - l + 1 - stand) {
				out.println(wg);
				System.exit(0);
			}

			out.println("No solution");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}


import java.io.*;
import java.math.*;
import java.util.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	boolean file = false;

	public static void main(String[] args) throws Exception {
		new Thread(new Solution()).start();
	}

	private String next() throws Exception {
		if (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	private long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public void run() {
		try {
			if (file)
				in = new BufferedReader(new FileReader("in.txt"));
			else
				in = new BufferedReader(new InputStreamReader(System.in));
			if (file)
				out = new PrintWriter(new FileWriter("out.txt"));
			else
				out = new PrintWriter(System.out);
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}
	public void solve() throws Exception {
		int n = nextInt(), k = nextInt();
		char name[] = next().toCharArray();
		char res[] = new char[n];
		Arrays.fill(res, '.');
		char[] pattern = next().toCharArray();
		for(int i=0; i<pattern.length; i++){
			if(pattern[i] == '1'){
				for(int pos = 0; pos<name.length; pos++){
					if(res[i+pos] == '.'){
						res[i+pos] = name[pos];
					}
					else{
						if(res[i+pos] != name[pos]){
							out.println("No solution"); return;
						}
					}
				}
			}
		}
		for(int i=0; i<pattern.length; i++){
			if(pattern[i] == '0' && match(res, i, name)){
				out.println("No solution"); return;
			}
		}
	//	out.println(new String(res));
		cut:for(int i=0; i<res.length; i++){
			if(res[i] == '.'){
				int cnt = 0;
				for(int bb = k-1; bb >= 0; bb--){
					res[i] = (char)('a'+bb);
					boolean flag = true;
					for(int j=0; j<pattern.length; j++){
						if(pattern[j] == '0' && match(res, j, name)){
							flag = false; break;
						}
					}
				//	out.println("res = "+(new String(res))+" and flag "+flag);
					if(flag){
						continue cut;
					}
					else cnt++;
				}
				if(cnt == k){
					out.println("No solution"); return;
				}
			}
		}
		out.println(new String(res));
	}
	public boolean match(char c[], int pos, char[] pat){
		for(int i=0; i<pat.length; i++){
			if(c[pos+i] != pat[i])return false;
		}
		return true;
	}
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

import javax.swing.JFileChooser;

public class Main {

    /**
     * @param args
     * @throws IOException
     */

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

         BufferedReader in = new BufferedReader(new InputStreamReader(
                 System.in));
         StringTokenizer a = new StringTokenizer(in.readLine());
         char[] song = new char[Integer.parseInt(a.nextToken())];
         for (int i = 0; i < song.length; i++) {
            song[i]=' ';
        }
         int chars = Integer.parseInt(a.nextToken());

         char[] name = in.readLine().toCharArray();
         int start = name[0]-'a';
         String oc = in.readLine();
         boolean co= false;
         for (int i = 0; i < oc.length(); i++) {
            if(oc.charAt(i)=='1'){
                for (int j = 0; j < name.length; j++) {
                    if(song[i+j]!=name[j]&&song[i+j]!=' '){co=true;break;}
                    song[i+j]=name[j];
                }
                if(co)break;
            }
        }
         if(co){
             System.out.println("No solution");
         }else{

             for (int bat = 0 ; bat < chars;bat++){
                 String print ="";
                 for (int i = 0; i < song.length; i++) {
                if(song[i]==' '){
                    print += (char) ('a'+bat);
                }else{
                    print+=song[i];
                }
            }
            if (check(print,oc,name)){co=true; System.out.println(print);break;}
            }
             if(!co){
                 System.out.println("No solution");
             }
         }

    }

    private static boolean check(String print, String oc, char[] name) {
        // TODO Auto-generated method stub
        char [] p = print.toCharArray();
        for (int i = 0; i < oc.length(); i++) {
            if(oc.charAt(i)=='0'){
                boolean bad = true;
                for (int j = 0; j < name.length; j++) {
                    if(name[j]!=p[i+j]){bad = false;break;}
                }
                if (bad)return false;
            }
        }

        return true;
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class WritingSong {
    static class Node {
        int id;
        Node fail;
        Node[] child;
        ArrayList<Integer> indices;
        boolean[] chars;

        public Node() {
            child = new Node[256];
            indices = new ArrayList<Integer>();
            chars = new boolean[256];
            id = -1;
        }

        void insert(String str, int index, int charIndex) {
            if (charIndex == str.length())
                indices.add(index);
            else {
                if (child[str.charAt(charIndex)] == null) {
                    child[str.charAt(charIndex)] = new Node();
                    chars[str.charAt(charIndex)] = true;
                }
                child[str.charAt(charIndex)].insert(str, index, charIndex + 1);
            }
        }
    }

    static Node build(ArrayList<String> words) {
        Node root = new Node();
        for (int i = 0; i < words.size(); i++)
            root.insert(words.get(i), i, 0);
        Queue<Node> q = new LinkedList<Node>();
        for (int i = 45; i < 125; i++) {
            if (root.child[i] == null)
                root.child[i] = root;
            else {
                q.add(root.child[i]);
                root.child[i].fail = root;
            }
        }
        while (!q.isEmpty()) {
            Node front = q.remove();
            for (int i = 45; i < 125; i++) {
                if (!front.chars[i])
                    continue;
                q.add(front.child[i]);
                Node temp = front.fail;
                while (temp.child[i] == null)
                    temp = temp.fail;
                temp = temp.child[i];
                front.child[i].fail = temp;
                front.child[i].indices.addAll(temp.indices);
            }
        }
        return root;
    }

    public static void dfs(Node n) {
        if (n.id != -1)
            return;
        n.id = id;
        nodes[id++] = n;
        for (int i = 45; i < 125; i++)
            if (n.chars[i]) {
                dfs(n.child[i]);
            }
    }

    static int id, n, k;
    static Node[] nodes = new Node[101];
    static String mask, s;
    static Integer[][] dp = new Integer[101][101];
    static char[][] path = new char[101][101];

    public static int go(int index, int node) {
        int start = index - s.length();
        if (start >= 0) {
            if (mask.charAt(start) == '1') {
                if (nodes[node].indices.size() == 0)
                    return 0;
            } else {
                if (nodes[node].indices.size() == 1)
                    return 0;
            }
        }

        if (index == n)
            return 1;
        if (dp[index][node] != null)
            return dp[index][node];
        int can = 0;
        for (int i = 0; i < k; i++) {
            Node temp = nodes[node];
            char c = (char) (i + 'a');
            while (temp.child[c] == null)
                temp = temp.fail;
            temp = temp.child[c];
            if (go(index + 1, temp.id) == 1) {
                can = 1;
                path[index][node] = c;
                break;
            }
        }
        return dp[index][node] = can;
    }

    public static void main(String[] args) {
        InputReader r = new InputReader(System.in);
        n = r.nextInt();
        k = r.nextInt();
        s = r.next();
        mask = r.next();
        ArrayList<String> arr = new ArrayList<String>();
        arr.add(s);
        Node root = build(arr);
        dfs(root);
        if (go(0, 0) == 0) {
            System.out.println("No solution");
            return;
        }
        int index = 0, node = 0;
        while (index < n) {
            System.out.print(path[index][node]);
            for (int i = 0; i < k; i++) {
                Node temp = nodes[node];
                char c = (char) (i + 'a');
                while (temp.child[c] == null)
                    temp = temp.fail;
                temp = temp.child[c];
                if (go(index + 1, temp.id) == 1) {
                    node = temp.id;
                    index++;
                    break;
                }
            }
        }
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return null;
            }
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

}


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		D solver = new D();
		solver.solve(1, in, out);
		out.close();
	}
}

class D {
    public boolean solved = false;
    public PrintWriter out;
    public StringBuilder res = new StringBuilder();
    public boolean[][] visited = new boolean[200][200];
    public int n;
    public int k;
    public int length;
    public String name;
    public boolean[] want;
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        this.out = out;
        n = in.nextInt();
        k = in.nextInt();
        name = in.next();
        length = name.length();
        char[] wantStr = in.next().toCharArray();
        want = new boolean[wantStr.length];
        for (int i = 0; i < want.length; i++) {
            want[i] = wantStr[i] == '1';
        }
        recurse(0, 0);
        if (!solved) {
            out.println("No solution");
        }
    }
    public void recurse(int idx, int state) {
        if (solved || visited[idx][state]) {
        }
        else if (idx >= length && (want[idx - length] ^ state == length)) {
        }
        else if (idx == n) {
            out.println(res);
            solved = true;
        }
        else {
            visited[idx][state] = true;
            for (int i = 0; i < k; i++) {
                res.append((char) ('a' + i));
                int max = 0;
                for (int j = 1; j <= length && j <= res.length(); j++) {
                    if (res.substring(res.length() - j).compareTo(name.substring(0, j)) == 0) {
                        max = j;
                    }
                }
                recurse(idx + 1, max);
                res.setLength(res.length() - 1);
            }
        }
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Words222 {
    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        String ps = nextToken();
        int[] p = new int[ps.length()];
        for (int i = 0; i < p.length; ++i)
            p[i] = ps.charAt(i) - 'a';
        String ms = nextToken();
        boolean[] match = new boolean[ms.length()];
        for (int i = 0; i < match.length; ++i)
            match[i] = ms.charAt(i) != '0';
        int[] l = new int[p.length + 1];
        for (int i = 2; i <= p.length; ++i) {
            int cur = l[i - 1];
            while (true) {
                if (p[cur] == p[i - 1]) {
                    ++cur;
                    break;
                }
                if (cur == 0) break;
                cur = l[cur];
            }
            l[i] = cur;
        }
        String[] way = new String[p.length + 1];
        way[0] = "";
        for (int i = 0; i < n; ++i) {
            String[] nway = new String[p.length + 1];
            for (int prev = 0; prev <= p.length; ++prev) {
                if (way[prev] == null)
                    continue;
                for (int c = 0; c < k; ++c) {
                    int cur = prev;
                    while (true) {
                        if (cur == p.length) {
                            cur = l[cur];
                            continue;
                        }
                        if (p[cur] == c) {
                            ++cur;
                            break;
                        }
                        if (cur == 0) break;
                        cur = l[cur];
                    }
                    if (nway[cur] == null) {
                        nway[cur] = way[prev] + (char) ('a' + c);
                    }
                }
            }
            if (i >= p.length - 1) {
                if (match[i - p.length + 1]) {
                    for (int j = 0; j < p.length; ++j)
                        nway[j] = null;
                } else {
                    nway[p.length] = null;
                }
            }
            way = nway;
        }
        String res = null;
        for (String x : way)
            if (x != null) {
                res = x;
                break;
            }
        if (res == null) res = "No solution";
        writer.println(res);
    }

    public static void main(String[] args) {
        new Words222().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Words222 {
    private void solve222() throws IOException {
        int n = nextInt();
        int k = nextInt();
        String ps = nextToken();
        int[] p = new int[ps.length()];
        for (int i = 0; i < p.length; ++i)
            p[i] = ps.charAt(i) - 'a';
        String ms = nextToken();
        boolean[] match = new boolean[ms.length()];
        for (int i = 0; i < match.length; ++i)
            match[i] = ms.charAt(i) != '0';
        int[] l = new int[p.length + 1];
        for (int i = 2; i <= p.length; ++i) {
            int cur = l[i - 1];
            while (true) {
                if (p[cur] == p[i - 1]) {
                    ++cur;
                    break;
                }
                if (cur == 0) break;
                cur = l[cur];
            }
            l[i] = cur;
        }
        String[] way = new String[p.length + 1];
        way[0] = "";
        for (int i = 0; i < n; ++i) {
            String[] nway = new String[p.length + 1];
            for (int prev = 0; prev <= p.length; ++prev) {
                if (way[prev] == null)
                    continue;
                for (int c = 0; c < k; ++c) {
                    int cur = prev;
                    while (true) {
                        if (cur == p.length) {
                            cur = l[cur];
                            continue;
                        }
                        if (p[cur] == c) {
                            ++cur;
                            break;
                        }
                        if (cur == 0) break;
                        cur = l[cur];
                    }
                    if (nway[cur] == null) {
                        nway[cur] = way[prev] + (char) ('a' + c);
                    }
                }
            }
            if (i >= p.length - 1) {
                if (match[i - p.length + 1]) {
                    for (int j = 0; j < p.length; ++j)
                        nway[j] = null;
                } else {
                    nway[p.length] = null;
                }
            }
            way = nway;
        }
        String res = null;
        for (String x : way)
            if (x != null) {
                res = x;
                break;
            }
        if (res == null) res = "No solution";
        writer.println(res);
    }

    public static void main(String[] args) {
        new Words222().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve222();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Words222 {
    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        String ps = nextToken();
        int[] p = new int[ps.length()];
        for (int i = 0; i < p.length; ++i)
            p[i] = ps.charAt(i) - 'a';
        String ms = nextToken();
        boolean[] match = new boolean[ms.length()];
        for (int i = 0; i < match.length; ++i)
            match[i] = ms.charAt(i) != '0';
        int[] l = new int[p.length + 1];
        for (int i = 2; i <= p.length; ++i) {
            int cur = l[i - 1];
            while (true) {
                if (p[cur] == p[i - 1]) {
                    ++cur;
                    break;
                }
                if (cur == 0) break;
                cur = l[cur];
            }
            l[i] = cur;
        }
        String[] way = new String[p.length + 1];
        way[0] = "";
        for (int i = 0; i < n; ++i) {
            String[] nway = new String[p.length + 1];
            for (int prev = 0; prev <= p.length; ++prev) {
                if (way[prev] == null)
                    continue;
                for (int c = 0; c < k; ++c) {
                    int cur = prev;
                    while (true) {
                        if (cur == p.length) {
                            cur = l[cur];
                            continue;
                        }
                        if (p[cur] == c) {
                            ++cur;
                            break;
                        }
                        if (cur == 0) break;
                        cur = l[cur];
                    }
                    if (nway[cur] == null) {
                        nway[cur] = way[prev] + (char) ('a' + c);
                    }
                }
            }
            if (i >= p.length - 1) {
                if (match[i - p.length + 1]) {
                    for (int j = 0; j < p.length; ++j)
                        nway[j] = null;
                } else {
                    nway[p.length] = null;
                }
            }
            way = nway;
        }
        String res = null;
        for (String x : way)
            if (x != null) {
                res = x;
                break;
            }
        if (res == null) res = "No solution";
        writer.println(res);
    }

    public static void main(String[] args) {
        new Words().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Words {
    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        String ps = nextToken();
        int[] p = new int[ps.length()];
        for (int i = 0; i < p.length; ++i)
            p[i] = ps.charAt(i) - 'a';
        String ms = nextToken();
        boolean[] match = new boolean[ms.length()];
        for (int i = 0; i < match.length; ++i)
            match[i] = ms.charAt(i) != '0';
        int[] l = new int[p.length + 1];
        for (int i = 2; i <= p.length; ++i) {
            int cur = l[i - 1];
            while (true) {
                if (p[cur] == p[i - 1]) {
                    ++cur;
                    break;
                }
                if (cur == 0) break;
                cur = l[cur];
            }
            l[i] = cur;
        }
        String[] way = new String[p.length + 1];
        way[0] = "";
        for (int i = 0; i < n; ++i) {
            String[] nway = new String[p.length + 1];
            for (int prev = 0; prev <= p.length; ++prev) {
                if (way[prev] == null)
                    continue;
                for (int c = 0; c < k; ++c) {
                    int cur = prev;
                    while (true) {
                        if (cur == p.length) {
                            cur = l[cur];
                            continue;
                        }
                        if (p[cur] == c) {
                            ++cur;
                            break;
                        }
                        if (cur == 0) break;
                        cur = l[cur];
                    }
                    if (nway[cur] == null) {
                        nway[cur] = way[prev] + (char) ('a' + c);
                    }
                }
            }
            if (i >= p.length - 1) {
                if (match[i - p.length + 1]) {
                    for (int j = 0; j < p.length; ++j)
                        nway[j] = null;
                } else {
                    nway[p.length] = null;
                }
            }
            way = nway;
        }
        String res = null;
        for (String x : way)
            if (x != null) {
                res = x;
                break;
            }
        if (res == null) res = "No solution";
        writer.println(res);
    }

    public static void main(String[] args) {
        new Words().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.util.Scanner;

public class C50D {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String p=sc.next();
        String or=sc.next();
        String res="";
        int l=0;
        int count=0;
        char cc;
        int ind=0;
        boolean ff=false;
        if(p.length()==1)
            cc = (p.charAt(0)=='a' ) ? 'b':'a';
        else
            cc=p.charAt(p.length()-1);

        for(int i=0;i<or.length();i++){
                if(or.charAt(i)=='1'){

                    if( i==or.length()-1 && i+p.length()>n ){
                       res="No solution";
                       break;
                    }
                    else{

                        if(count==0){
                            res=res+p;
                            ind=i;
                            count=1;
                        }
                        else{
                            if( i+p.length()<=n && (res.substring(i,res.length()).equals(p.substring(0,res.length()-i)))){
                                res+=p.substring(res.length()-i,p.length());
                                for(int h=ind+1;h<res.length()-p.length();h++){
                                    if(res.substring(h,h+p.length()).equals(p)){

                                        res="No solution";
                                        ff=true;

                                    }
                                }
                                if(ff)break;
                                ind=i;

                            }
                            else{
                                 res="No solution";

                                 break;
                            }

                        }
                     }
                }
         else{

                    if(i==0 ||res.length()<=i)
                        res+=String.valueOf(cc);

        }
        }

        System.out.println(res);

    }
}


import java.util.Scanner;

public class C50D {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String p=sc.next();
        String or=sc.next();
        String res="";
        int l=0;
        int count=0;
        char cc;
        if(p.length()==1)
            cc = (p.charAt(0)=='a' ) ? 'b':'a';
        else
            cc=p.charAt(p.length()-1);

        for(int i=0;i<or.length();i++){
                if(or.charAt(i)=='1'){

                    if( i==or.length()-1 && i+p.length()>n ){
                       res="No solution";

                       break;
                    }
                    else{

                        if(count==0){
                            res=p;

                            count=1;
                        }
                        else{
                            if( i+p.length()<=n && (res.substring(i,res.length()).equals(p.substring(0,res.length()-i)))){
                                res+=p.substring(res.length()-i,p.length());

                            }
                            else{
                                 res="No solution";

                                 break;
                            }

                        }
                     }
                }
         else{
                    if(res.length()<=i)
                        res+=String.valueOf(cc);

        }
        }

        System.out.println(res);

    }
}


import java.util.Scanner;

public class C50D {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String p=sc.next();
        String or=sc.next();
        String res="";
        int l=0;
        int count=0;
        char cc;
        if(p.length()==1)
            cc = (p.charAt(0)=='a' ) ? 'b':'a';
        else
            cc=p.charAt(p.length()-1);

        for(int i=0;i<or.length();i++){
                if(or.charAt(i)=='1'){

                    if( i==or.length()-1 && i+p.length()>n ){
                       res="No solution";

                       break;
                    }
                    else{

                        if(count==0){
                            res+=p;

                            count=1;
                        }
                        else{
                            if( i+p.length()<=n && (res.substring(i,res.length()).equals(p.substring(0,res.length()-i)))){
                                res+=p.substring(res.length()-i,p.length());

                            }
                            else{
                                 res="No solution";

                                 break;
                            }

                        }
                     }
                }
         else{
                    if(i==0 || res.length()<=i)
                        res+=String.valueOf(cc);

        }
        }

        System.out.println(res);

    }
}


import java.util.Scanner;

public class C50D {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String p=sc.next();
        String or=sc.next();
        String res="";
        int l=0;
        int count=0;
        char cc;
        int ind=0;
        boolean ff=false;
        for(int i=0;i<p.length()-1;i++){
            if(p.charAt(i)!=p.charAt(i+1)){
                ff=true;
                break;
            }
        }
        if(p.length()==1 || !ff)
            cc = (p.charAt(0)=='a' ) ? 'b':'a';
        else
            cc=p.charAt(p.length()-1);

        ff=false;
        for(int i=0;i<or.length();i++){
                if(or.charAt(i)=='1'){

                    if( i==or.length()-1 && i+p.length()>n ){
                       res="No solution";
                       break;
                    }
                    else{

                        if(count==0){
                            res=res+p;
                            ind=i;
                            count=1;
                        }
                        else{
                            if( i+p.length()<=n && (res.substring(i,res.length()).equals(p.substring(0,res.length()-i)))){
                                res+=p.substring(res.length()-i,p.length());
                                for(int h=ind+1;h<res.length()-p.length();h++){
                                    if(res.substring(h,h+p.length()).equals(p)){

                                        res="No solution";
                                        ff=true;

                                    }
                                }
                                if(ff)break;
                                ind=i;

                            }
                            else{
                                 res="No solution";
                                 break;
                            }

                        }
                     }
                }
         else{

                    if(i==0 ||res.length()<=i)
                        res+=String.valueOf(cc);

        }
        }

        System.out.println(res);

    }
}


import java.util.Scanner;

public class C50D {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String p=sc.next();
        String or=sc.next();
        String res="";
        int l=0;
        int count=0;
        char cc;
        int ind=0;
        boolean ff=false,f=false;
        for(int i=0;i<p.length()-1;i++){
            if(p.charAt(i)!=p.charAt(i+1)){
                ff=true;
                break;
            }
        }
        if(p.length()==1 || !ff)
            cc = (p.charAt(0)=='a' ) ? 'b':'a';
        else
            cc=p.charAt(p.length()-1);

        ff=false;
        for(int i=0;i<or.length();i++){
                if(or.charAt(i)=='1'){

                    if( i==or.length()-1 && i+p.length()>n ){
                       res="No solution";
                       f=true;
                       break;
                    }
                    else{

                        if(count==0){
                            res=res+p;
                            ind=i;
                            count=1;
                        }
                        else{
                            if( i+p.length()<=n && (res.substring(i,res.length()).equals(p.substring(0,res.length()-i)))){
                                res+=p.substring(res.length()-i,p.length());
                                for(int h=ind+1;h<res.length()-p.length();h++){
                                    if(res.substring(h,h+p.length()).equals(p)){
                                        f=true;
                                        res="No solution";
                                        ff=true;

                                    }
                                }
                                if(ff)break;
                                ind=i;

                            }
                            else{
                                f=true;
                                 res="No solution";
                                 break;
                            }

                        }
                     }
                }
         else{

                    if(i==0 ||res.length()<=i)
                        res+=String.valueOf(cc);

        }
        }
        if(!f){
            for(int i=res.length();i<n;i++)
                res+=String.valueOf(cc);
            }
        System.out.println(res);

    }
}


import java.util.Scanner;

public class C50D {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String p=sc.next();
        String or=sc.next();
        String res="";
        int l=0;
        int count=0;
        char cc;
        int ind=0;
        boolean ff=false,f=false;
        for(int i=0;i<p.length()-1;i++){
            if(p.charAt(i)!=p.charAt(i+1)){
                ff=true;
                break;
            }
        }
        if(p.length()==1 || !ff)
            cc = (p.charAt(0)=='a' ) ? 'b':'a';
        else
            cc=p.charAt(p.length()-1);

        ff=false;
        for(int i=0;i<or.length();i++){
                if(or.charAt(i)=='1'){

                    if( i==or.length()-1 && i+p.length()>n ){
                       res="No solution";
                       f=true;
                       break;
                    }
                    else{

                        if(count==0){
                            res=res+p;
                            ind=i;
                            count=1;
                        }
                        else{
                            if( i+p.length()<=n && (res.substring(i,res.length()).equals(p.substring(0,res.length()-i)))){
                                res+=p.substring(res.length()-i,p.length());
                                for(int h=ind+1;h<res.length()-p.length();h++){
                                    if(res.substring(h,h+p.length()).equals(p)){
                                        f=true;
                                        res="No solution";
                                        ff=true;

                                    }
                                }
                                if(ff)break;
                                ind=i;

                            }
                            else{
                                f=true;
                                 res="No solution";
                                 break;
                            }

                        }
                     }
                }
         else{

                    if(i==0 ||res.length()<=i)
                        res+=String.valueOf(cc);

        }
        }
        if(!f){
            for(int i=or.length();i<n;i++)
                res+=String.valueOf(cc);
            }
        System.out.println(res);

    }
}


import java.io.*;
import java.util.*;

public class Solution implements Runnable {

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	private void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();
		char[] w = next().toCharArray();
		boolean[] match = new boolean[n + 1];
		char[] tmp = next().toCharArray();
		for (int i = w.length; i <= n; ++i) {
			match[i] = tmp[i - w.length] == '1';
		}
		int[] pf = new int[w.length];
		for (int i = 1; i < w.length; ++i) {
			pf[i] = pf[i - 1];
			while (pf[i] > 0 && w[i] != w[pf[i]]) {
				pf[i] = pf[pf[i] - 1];
			}
			if (w[i] == w[pf[i]]) {
				pf[i]++;
			}
		}
		int[][] au = new int[w.length + 1][k];
		for (int i = 0; i <= w.length; ++i) {
			for (int j = 0; j < k; ++j) {
				char c = (char) ('a' + j);
				int st = i;
				while (st != 0 && (st == w.length || w[st] != c)) {
					st = pf[st - 1];
				}
				if (w[st] == c) {
					++st;
				}
				au[i][j] = st;
			}
		}
		int[][] p = new int[n + 1][w.length + 1];
		char[][] pc = new char[n + 1][w.length + 1];
		for (int i = 0; i <= n; ++i) {
			Arrays.fill(p[i], -1);
		}
		p[0][0] = -2;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j <= w.length; ++j) {
				if (p[i][j] == -1) {
					continue;
				}
				for (int c = 0; c < k; ++c) {
					int jj = au[j][c];
					if ((jj == w.length) != match[i + 1]) {
						continue;
					}
					p[i + 1][jj] = j;
					pc[i + 1][jj] = (char) ('a' + c);
				}
			}
		}
		int last = -1;
		for (int i = 0; i <= w.length; ++i) {
			if (p[n][i] != -1) {
				last = i;
			}
		}
		if (last == -1) {
			out.println("No solution");
			return;
		}
		StringBuilder ans = new StringBuilder();
		for (int i = n, j = last; i > 0; j = p[i--][j]) {
			ans.append(pc[i][j]);
		}
		out.println(ans.reverse().toString());
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			eat("");

			solve();

			in.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	private void eat(String line) {
		st = new StringTokenizer(line);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) {
		new Thread(new Solution()).start();
	}

}


import java.io.*;
import java.util.*;
import java.math.*;

public class D implements Runnable {

	void solve() {
		int n = nextInt();
		int k = nextInt();
		String s = nextToken();
		String t = nextToken();
		System.err.println(s.length());
		System.err.println(t.length());
		char[] ans = new char[n];
		Arrays.fill(ans, '?');
		for (int i = 0; i < t.length(); i++) {
			if (t.charAt(i) == '0') {
				continue;
			}
			for (int j = 0; j < s.length(); j++) {
				char ch = s.charAt(j);
				if (ans[i + j] != '?' && ans[i + j] != ch) {
					out.println("No solution");
					return;
				}
				ans[i + j] = ch;
			}
		}
		long time = System.currentTimeMillis();
		loop: while (true) {
			if (System.currentTimeMillis() - time > 1700) {
				System.err.println("time is up");
				out.println("No solution");
				return;
			}
			char[] d = ans.clone();
			for (int i = 0; i < d.length; i++) {
				if (d[i] == '?') {
					boolean found = false;
					for (int j = 0; j < 7; j++) {
						int x = rand.nextInt(k);
						d[i] = (char) (x + 'a');
						boolean ok = true;
						for (int r = Math.max(0, i - s.length() + 1); r <= i
								&& r + s.length() <= n; r++) {
							if (new String(d, r, s.length()).equals(s)) {
								ok = false;
								break;
							}
						}
						if (ok) {
							found = true;
							break;
						}
					}
					if (!found) {
						continue loop;
					}
				}
			}
			String e = new String(d);
			for (int i = 0; i < t.length(); i++) {
				boolean has = t.charAt(i) == '1';
				if (e.substring(i, i + s.length()).equals(s) != has) {
					throw new AssertionError();
				}
			}
			out.println(e);
			return;
		}
	}

	FastScanner sc;
	PrintWriter out;
	Random rand = new Random(this.hashCode());

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	BigInteger nextBigInteger() {
		return sc.nextBigInteger();
	}

	class FastScanner extends BufferedReader {
		StringTokenizer st;
		boolean eof;
		String buf;
		String curLine;
		boolean createST;

		public FastScanner(String fileName) throws FileNotFoundException {
			this(fileName, true);
		}

		public FastScanner(String fileName, boolean createST)
				throws FileNotFoundException {
			super(new FileReader(fileName));
			this.createST = createST;
			nextToken();
		}

		public FastScanner(InputStream stream) {
			this(stream, true);
		}

		public FastScanner(InputStream stream, boolean createST) {
			super(new InputStreamReader(stream));
			this.createST = createST;
			nextToken();
		}

		String nextLine() {
			String ret = curLine;
			if (createST) {
				st = null;
			}
			nextToken();
			return ret;
		}

		String nextToken() {
			if (!createST) {
				try {
					curLine = readLine();
				} catch (Exception e) {
					eof = true;
				}
				return null;
			}
			while (st == null || !st.hasMoreTokens()) {
				try {
					curLine = readLine();
					st = new StringTokenizer(curLine);
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		BigInteger nextBigInteger() {
			return new BigInteger(nextToken());
		}

		public void close() {
			try {
				buf = null;
				st = null;
				curLine = null;
				super.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	public static void main(String[] args) {
		new D().run();
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class D implements Runnable {

	void solve() {
		int n = nextInt();
		int k = nextInt();
		String s = nextToken();
		String t = nextToken();
		System.err.println(s.length());
		System.err.println(t.length());
		char[] ans = new char[n];
		Arrays.fill(ans, '?');
		for (int i = 0; i < t.length(); i++) {
			if (t.charAt(i) == '0') {
				continue;
			}
			for (int j = 0; j < s.length(); j++) {
				char ch = s.charAt(j);
				if (ans[i + j] != '?' && ans[i + j] != ch) {
					out.println("No solution");
					return;
				}
				ans[i + j] = ch;
			}
		}
		long time = System.currentTimeMillis();
		loop: while (true) {
			if (System.currentTimeMillis() - time > 1700) {
				System.err.println("time is up");
				out.println("No solution");
				return;
			}
			char[] d = ans.clone();
			for (int i = 0; i < d.length; i++) {
				if (d[i] == '?') {
					boolean found = false;
					for (int j = 0; j < 7; j++) {
						int x = rand.nextInt(k);
						d[i] = (char) (x + 'a');
						boolean ok = true;
						for (int r = Math.max(0, i - s.length() + 1); r <= i
								&& r + s.length() <= n; r++) {
							if (new String(d, r, s.length()).equals(s)) {
								ok = false;
								break;
							}
						}
						if (ok) {
							found = true;
							break;
						}
					}
					if (!found) {
						continue loop;
					}
				}
			}
			String e = new String(d);
			for (int i = 0; i < t.length(); i++) {
				boolean has = t.charAt(i) == '1';
				if (e.substring(i, i + s.length()).equals(s) != has) {
					continue loop;
				}
			}
			out.println(e);
			return;
		}
	}

	FastScanner sc;
	PrintWriter out;
	Random rand = new Random(this.hashCode());

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	BigInteger nextBigInteger() {
		return sc.nextBigInteger();
	}

	class FastScanner extends BufferedReader {
		StringTokenizer st;
		boolean eof;
		String buf;
		String curLine;
		boolean createST;

		public FastScanner(String fileName) throws FileNotFoundException {
			this(fileName, true);
		}

		public FastScanner(String fileName, boolean createST)
				throws FileNotFoundException {
			super(new FileReader(fileName));
			this.createST = createST;
			nextToken();
		}

		public FastScanner(InputStream stream) {
			this(stream, true);
		}

		public FastScanner(InputStream stream, boolean createST) {
			super(new InputStreamReader(stream));
			this.createST = createST;
			nextToken();
		}

		String nextLine() {
			String ret = curLine;
			if (createST) {
				st = null;
			}
			nextToken();
			return ret;
		}

		String nextToken() {
			if (!createST) {
				try {
					curLine = readLine();
				} catch (Exception e) {
					eof = true;
				}
				return null;
			}
			while (st == null || !st.hasMoreTokens()) {
				try {
					curLine = readLine();
					st = new StringTokenizer(curLine);
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		BigInteger nextBigInteger() {
			return new BigInteger(nextToken());
		}

		public void close() {
			try {
				buf = null;
				st = null;
				curLine = null;
				super.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	public static void main(String[] args) {
		new D().run();
	}
}


//package round50;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class D {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		int k = ni();
		char[] p = in.next().toCharArray();
		char[] sh = in.next().toCharArray();
		int[] ret = new int[n];
		Arrays.fill(ret, (1<<k)-1);
		for(int i = 0;i < sh.length;i++){
			for(int j = 0;j < p.length;j++){
				char c = p[j];
				int code = 1<<(c-'a');
				if(sh[i] == '1'){
					ret[i+j] &= code;
				}else{
					ret[i+j] &= ~code;
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < ret.length;i++){
			if(ret[i] == 0){
				out.println("No solution");
				return;
			}
			for(int j = 0;j < k;j++){
				if(((ret[i]>>j)&1) == 1){
					sb.append((char)('a'+j));
				}
			}
		}

		out.println(sb.toString());
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

	public static void main(String[] args) throws Exception
	{
		new D().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


//package round50;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;

public class D {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		int k = ni();
		char[] p = in.next().toCharArray();
		char[] sh = in.next().toCharArray();
		int[] ret = new int[n];
		Arrays.fill(ret, (1<<k)-1);
		BitSet stock = new BitSet();
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < n;i++){
			int code = (1<<k)-1;
			for(int j = 0;j <= i && j < sh.length;j++){
				if(sh[j] == '1' && i < j + p.length){
					code &= 1<<(p[i-j]-'a');
				}
			}
			if(code == 0){
				out.println("No solution");
				return;
			}
			for(int j = 0;j <= i && j < sh.length;j++){
				if(sh[j] == '0' && i < j + p.length && !stock.get(j)){
					int nc = code & (~(1<<(p[i-j]-'a')));
					if(nc == 0)continue;
					code = nc;
					stock.set(j);
				}
			}
			for(int j = 0;j < k;j++){
				if(((code>>j)&1) == 1){
					sb.append((char)('a'+j));
					break;
				}
			}
		}

		for(int j = 0;j < sh.length;j++){
			if(sh[j] == '0'){
				if(!stock.get(j)){
					out.println("No solution");
					return;
				}
			}
		}

		out.println(sb.toString());
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

	public static void main(String[] args) throws Exception
	{
		new D().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	int N;
	int K;
	int L;
	char[] name;
	char[] match;
	char[] ans;
	char[] buf;

	boolean ok = true;

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		N = nextInt();
		K = nextInt();
		name = nextToken().toCharArray();
		L = name.length;
		match = nextToken().toCharArray();

		ans = new char [N];

		for (int i = 0; i < N - L + 1; i++)
			if (match[i] == '1') {
				if (!print(i)) {
					ok = false;
					break;
				}
			}

		if (ok) {
			ok = false;
			for (int i = 0; i < K; i++){
				buf = Arrays.copyOf(ans, N);
				for (int j = 0; j < N; j++)
					if (buf[j] == 0)
						buf[j] = (char) ('a' + i);
				if (check(buf)) {
					ans = buf;
					ok = true;
					break;
				}
			}
		}

		if (ok)
			out.println(ans);
		else
			out.println("No solution");

		out.close();
	}

	boolean check(char[] s) {
		for (int i = 0; i < N - L + 1; i++)
			if (match[i] != match(s, i))
				return false;
		return true;
	}

	char match(char[] s, int start) {
		for (int i = 0; i < L; i++)
			if (s[start + i] != name[i])
				return '0';
		return '1';
	}

	boolean print(int start) {
		for (int i = 0; i < L; i++)
			if (ans[start + i] == 0 || ans[start + i] == name[i])
				ans[start + i] = name[i];
			else
				return false;
		return true;
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();

			if (s == null) {
				return true;
			}

			st = new StringTokenizer(s);
		}

		return false;
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Words implements Runnable {
    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        String ps = nextToken();
        int[] p = new int[ps.length()];
        for (int i = 0; i < p.length; ++i)
            p[i] = ps.charAt(i) - 'a';
        String ms = nextToken();
        boolean[] match = new boolean[ms.length()];
        for (int i = 0; i < match.length; ++i)
            match[i] = ms.charAt(i) != '0';
        int[] l = new int[p.length + 1];
        for (int i = 2; i <= p.length; ++i) {
            int cur = l[i - 1];
            while (true) {
                if (p[cur] == p[i - 1]) {
                    ++cur;
                    break;
                }
                if (cur == 0) break;
                cur = l[cur];
            }
            l[i] = cur;
        }
        String[] way = new String[p.length + 1];
        way[0] = "";
        for (int i = 0; i < n; ++i) {
            String[] nway = new String[p.length + 1];
            for (int prev = 0; prev <= p.length; ++prev) {
                if (way[prev] == null)
                    continue;
                for (int c = 0; c < k; ++c) {
                    int cur = prev;
                    while (true) {
                        if (cur == p.length) {
                            cur = l[cur];
                            continue;
                        }
                        if (p[cur] == c) {
                            ++cur;
                            break;
                        }
                        if (cur == 0) break;
                        cur = l[cur];
                    }
                    if (nway[cur] == null) {
                        nway[cur] = way[prev] + (char) ('a' + c);
                    }
                }
            }
            if (i >= p.length - 1) {
                if (match[i - p.length + 1]) {
                    for (int j = 0; j < p.length; ++j)
                        nway[j] = null;
                } else {
                    nway[p.length] = null;
                }
            }
            way = nway;
        }
        String res = null;
        for (String x : way)
            if (x != null) {
                res = x;
                break;
            }
        if (res == null) res = "No solution";
        writer.println(res);
    }

    public static void main(String[] args) {
        new Words().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import sun.tools.tree.ArrayAccessExpression;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Words implements Runnable {
    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        String ps = nextToken();
        int[] p = new int[ps.length()];
        for (int i = 0; i < p.length; ++i)
            p[i] = ps.charAt(i) - 'a';
        String ms = nextToken();
        boolean[] match = new boolean[ms.length()];
        for (int i = 0; i < match.length; ++i)
            match[i] = ms.charAt(i) != '0';
        int[] l = new int[p.length + 1];
        for (int i = 2; i <= p.length; ++i) {
            int cur = l[i - 1];
            while (true) {
                if (p[cur] == p[i - 1]) {
                    ++cur;
                    break;
                }
                if (cur == 0) break;
                cur = l[cur];
            }
            l[i] = cur;
        }
        String[] way = new String[p.length + 1];
        way[0] = "";
        for (int i = 0; i < n; ++i) {
            String[] nway = new String[p.length + 1];
            for (int prev = 0; prev <= p.length; ++prev) {
                if (way[prev] == null)
                    continue;
                for (int c = 0; c < k; ++c) {
                    int cur = prev;
                    while (true) {
                        if (cur == p.length) {
                            cur = l[cur];
                            continue;
                        }
                        if (p[cur] == c) {
                            ++cur;
                            break;
                        }
                        if (cur == 0) break;
                        cur = l[cur];
                    }
                    if (nway[cur] == null) {
                        nway[cur] = way[prev] + (char) ('a' + c);
                    }
                }
            }
            if (i >= p.length - 1) {
                if (match[i - p.length + 1]) {
                    for (int j = 0; j < p.length; ++j)
                        nway[j] = null;
                } else {
                    nway[p.length] = null;
                }
            }
            way = nway;
        }
        String res = null;
        for (String x : way)
            if (x != null) {
                res = x;
                break;
            }
        if (res == null) res = "No solution";
        writer.println(res);
    }

    public static void main(String[] args) {
        new Words().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


#include <cstdio>
#include <cstring>

//#define dbg(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define dbg(fmt, ...)

const int MAXN = 102, ALPHABET_SIZE = 26;
char shouldOccur[MAXN];

// KMP's next
int next[MAXN];
// prefix[pref_len][C], 已匹配 pref_len 个字符，下一个字符为 C，所匹配的 pref_len
int prefix[MAXN][ALPHABET_SIZE];
// cando[pos][pref_len], 在 pos 位置处匹配 pref_len 个字符是否可行
bool cando[MAXN][MAXN];

// pattern [1...plen]
void calc_next(char *pattern, int plen){
    int i, j = 0;
    for (i = 2; i <= plen; ++i){
        while (j > 0 && pattern[i] != pattern[j + 1]){
            j = next[j];
        }
        if (pattern[i] == pattern[j + 1]){
            j++;
        }
        next[i] = j;
    }
}

void calc_prefix(char *pattern, int plen, int alphaSize){
    int i, C, j;
    for (i = 0; i <= plen; ++i){
        for (C = 0; C < alphaSize; ++C){
            j = i;
            if (j == plen) j = next[j];
            while (j > 0 &&  C != pattern[j + 1]){
                j = next[j];
            }
            if (C == pattern[j + 1]){
                j++;
            }
            prefix[i][C] = j;
        }
    }
}

void calc_cando(int N, int alphaSize, int plen){
    cando[0][0] = true;

    int i, j, C;
    for (i = 0; i <= N; ++i){
        // 每一个状态继续进行迭代时，需要经过正确性检查
        if (shouldOccur[i]){
            for (j = 0; j < plen; ++j) cando[i][j] = false;
        }else{
            cando[i][plen] = false;
        }
        if (i == N) break;
        for (j = 0; j <= plen; ++j){
            if (cando[i][j]){
                dbg("(%d, %d) cando\n", i, j);
                for (C = 0; C < alphaSize; ++C){
                    int p = prefix[j][C];
                    cando[i+1][p] = true;
                    dbg("new prefix_len = %d\n", p);
                }
            }
        }
    }
}

void print_answer(int N, int K, int plen, int pref_len){
    char ans[MAXN];
    int i, j, C;

    for (i = N - 1; i >= 0; --i){
        bool found = false;
        for (j = 0; j <= plen && !found; ++j){
            if (!cando[i][j]) continue;
            for (C = 0; C < K; ++C){
                if (prefix[j][C] == pref_len){
                    ans[i+1] = C;
                    pref_len = j;
                    found = true;
                    break;
                }
            }
        }
    }

    for (i = 1; i <= N; ++i){
        putchar(ans[i] + 'a');
    }
    putchar('\n');
}

int main(){
    int N, K;
    char P[MAXN];
    int plen;
    scanf("%d %d", &N, &K);
    scanf("%s", P+1);
    plen = strlen(P+1);
    scanf("%s", shouldOccur+plen);

    int i;
    for (i = 1; i <= plen; ++i){
        P[i] -= 'a';
    }
    for (i = plen; i <= N; ++i){
        shouldOccur[i] -= '0';
    }

    calc_next(P, plen);
    for (i = 1; i <= plen; ++i){
        dbg("next[%d] = %d\n", i, next[i]);
    }
    calc_prefix(P, plen, K);
    calc_cando(N, K, plen);

    bool ok = false;
    int ok_pref_len;
    for (i = 0; i <= plen; ++i){
        if (cando[N][i]){
            ok = true;
            ok_pref_len = i;
            break;
        }
    }
    if (ok){
        print_answer(N, K, plen, ok_pref_len);
    }else{
        printf("No solution\n");
    }
    return 0;
}


#include <cstdio>
#include <cstring>

//#define dbg(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define dbg(fmt, ...)

const int MAXN = 102, ALPHABET_SIZE = 26;
char shouldOccur[MAXN];

// KMP's next
int next[MAXN];
// prefix[pref_len][C], 已匹配 pref_len 个字符，下一个字符为 C，所匹配的 pref_len
int prefix[MAXN][ALPHABET_SIZE];
// cando[pos][pref_len], 在 pos 位置处匹配 pref_len 个字符是否可行
bool cando[MAXN][MAXN];
int pre[MAXN][MAXN];

// pattern [1...plen]
void calc_next(char *pattern, int plen){
    int i, j = 0;
    for (i = 2; i <= plen; ++i){
        while (j > 0 && pattern[i] != pattern[j + 1]){
            j = next[j];
        }
        if (pattern[i] == pattern[j + 1]){
            j++;
        }
        next[i] = j;
    }
}

void calc_prefix(char *pattern, int plen, int alphaSize){
    int i, C, j;
    for (i = 0; i <= plen; ++i){
        for (C = 0; C < alphaSize; ++C){
            j = i;
            if (j == plen) j = next[j];
            while (j > 0 &&  C != pattern[j + 1]){
                j = next[j];
            }
            if (C == pattern[j + 1]){
                j++;
            }
            prefix[i][C] = j;
        }
    }
}

void calc_cando(int N, int alphaSize, int plen){
    cando[0][0] = true;
    pre[0][0] = -1;

    int i, j, C;
    for (i = 0; i <= N; ++i){
        if (shouldOccur[i]){
            for (j = 0; j < plen; ++j) cando[i][j] = false;
        }else{
            cando[i][plen] = false;
        }
        if (i == N) break;
        for (j = 0; j <= plen; ++j){
            if (cando[i][j]){
                dbg("(%d, %d) cando\n", i, j);
                for (C = 0; C < alphaSize; ++C){
                    int p = prefix[j][C];
                    cando[i+1][p] = true;
                    pre[i+1][p] = j;
                    dbg("new prefix_len = %d\n", p);
                }
            }
        }
    }
}

void print_answer(int N, int K, char *pattern, int pref_len){
    char ans[MAXN], noFirstC;
    int i;

    for (i = 0; i < K; ++i){
        if (i != pattern[1]){
            noFirstC = i;
            break;
        }
    }

    for (i = N; i > 0; --i){
        if (pref_len == 0){
            ans[i] = noFirstC;
        }else{
            ans[i] = pattern[pref_len];
        }
        pref_len = pre[i][pref_len];
    }

    for (i = 1; i <= N; ++i){
        putchar(ans[i] + 'a');
    }
    putchar('\n');
}

int main(){
    int N, K;
    char P[MAXN];
    int plen;
    scanf("%d %d", &N, &K);
    scanf("%s", P+1);
    plen = strlen(P+1);
    scanf("%s", shouldOccur+plen);

    int i;
    for (i = 1; i <= plen; ++i){
        P[i] -= 'a';
    }
    for (i = plen; i <= N; ++i){
        shouldOccur[i] -= '0';
    }

    calc_next(P, plen);
    for (i = 1; i <= plen; ++i){
        dbg("next[%d] = %d\n", i, next[i]);
    }
    calc_prefix(P, plen, K);
    calc_cando(N, K, plen);

    bool ok = false;
    int ok_pref_len;
    for (i = 0; i <= plen; ++i){
        if (cando[N][i]){
            ok = true;
            ok_pref_len = i;
            break;
        }
    }
    if (ok){
        print_answer(N, K, P, ok_pref_len);
    }else{
        printf("No solution\n");
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define for1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define debug(x) {cerr << #x << " = " << x << endl;}
template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)1E9 + 7;
const ld EPS = 1E-9;
const ld PI = 3.1415926535897932384626433832795;

struct state{
    int next[30];
    state(){
        memset(next, -1, sizeof next);
    }
    int& operator [] (char c){
        return next[c-'a'];
    }
};

vector<state> t;

void build(string s, int k){
    vector<int> p(sz(s));
    fore(i, 1, sz(s)){
        int j = p[i-1];
        while(j > 0 && s[i] != s[j])
            j = p[j - 1];
        if(s[i] == s[j])
            p[i] = j+1;
    }

    forn(i, sz(s)+1){
        state cur;
        for(int c = 'a'; c < 'a'+k; c++){

            int j = i;
            while(j > 0 && (j >= sz(s) || s[j] != c))
                j = p[j-1];

            if(s[j] == c)
                cur[c] = j+1;
            else
                cur[c] = 0;
        }
        t.pb(cur);
    }
}

int n, k;
string s, tmp;

int have[110], d[110][110];

char ans[110];

void dfs(int i, int L){
    if(d[i][L]) return;

    d[i][L] = true;
    int curhave = int(L==sz(s));
    if(have[i] != curhave) return;

    if(i == n){
        forn(j, n)
            printf("%c", ans[j]);
        puts("");
        exit(0);
    }

    for(char c = 'a'; c < 'a'+k; c++){
        ans[i] = c;

        dfs(i+1, t[L][c]);

        ans[i] = '.';
    }
}

int main() {
    #ifdef my_project
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    #endif

    cin >> n >> k >> s >> tmp;

    build(s, k);
    forn(i, sz(tmp))
        if(tmp[i] == '1')
            have[i+sz(s)] = true;

    dfs(0,0);

    puts("No solution");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <cmath>
#include <string>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for ((i) = (a); i < (b); ++i)
#define inf 1000000000

bool prost(int x)
 {
    if (x<2) return false;
    else
     {
      int i;
      for (i = 2; i * i <= x; ++i)
         if (x%i == 0) return false;
      return true;

     }
 }

vector <int> Q;
vector <int> Y;
int n,i,j;
string s;
vector <int> pr;
int R[30];

int A[2000] = {0};

int main()
{
     cin >> s;
     n = s.size();
     FOR(i,2,n+1)
      if (prost(i)) pr.pb(i);

     memset(R,0,sizeof(R));

     FOR(i,0,s.size())
       ++R[s[i]-'a'];

     if (pr.size()<2)
      {
       cout<<"YES"<<endl;
       cout<<s<<endl;
      }
     else
      {
         int NW = 0;
         FOR(i,1,pr.size())
           if (pr[i]*2>n)
            {
             NW = i;
             break;
            }
         if (NW == 0)
          {
            FOR(i,0,26)
               if (R[i])
                {
                 Q.pb(R[i]);
                 Y.pb(i);
                }

            if (Q.size()>100) cout << "NO" << endl;
             else
              {
               FOR(i,0,Q.size())
                FOR(j,i+1,Q.size())
                  if (Q[i] < Q[j])
                   {
                     swap(Q[i],Q[j]);
                     swap(Y[i],Y[j]);
                   }
               if (Q[0] < n-1) cout << "NO" << endl;
                else
                 {
                  if (Q.size() == 1)
                   {
                    cout << "YES" << endl;
                    FOR(i,0,s.size())
                      cout << (char)(Y[0]+'a');
                    cout << endl;
                   }
                  else
                   {
                    cout << "YES" << endl;
                    cout << (char)(Y[1]+'a');
                    FOR(i,1,s.size())
                        cout << (char)(Y[0]+'a');
                    cout << endl;
                   }
                 }
              }
          }
         else
          {
             FOR(i,0,26)
               if (R[i])
                {
                 Q.pb(R[i]);
                 Y.pb(i);
                }

             FOR(i,0,Q.size())
              FOR(j,i+1,Q.size())
               if (Q[i] < Q[j])
                {
                 swap(Q[i],Q[j]);
                 swap(Y[i],Y[j]);
                }

             FOR(i,0,n)
                if ((i+1)%2 == 0)
                  {
                      if (!Q[0])
                       {
                         cout << "NO" << endl;
                         exit(0);
                       }
                      else
                       {
                          A[i] = Y[0];
                          Q[0]--;
                       }
                  }

             FOR(i,1,NW)
                if (!Q[0])
                 {
                  cout << "NO" << endl;
                  exit(0);
                 }
                else
                 {
                    A[pr[i]-1] = Y[0];
                    --Q[0];
                 }

             FOR(i,NW,pr.size())
                {
                      FOR(j,0,Q.size())
                        if (Q[j] != 0)
                          {
                           Q[j]--;
                           A[pr[i]-1] = Y[j];
                           break;
                          }
                }

             FOR(i,0,Q.size())
                 if (Q[i] != 0)
                   {
                    Q[i]--;
                    A[0] =  Y[i];
                    break;
                   }
             cout << "YES" << endl;
             FOR(i,0,n)
               cout << (char)('a'+A[i]);
             cout << endl;
          }
      }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <cmath>
#include <string>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for ((i) = (a); i < (b); ++i)
#define inf 1000000000

bool prost(int x)
 {
    if (x<2) return false;
    else
     {
      int i;
      for (i = 2; i * i <= x; ++i)
         if (x%i == 0) return false;
      return true;

     }
 }

vector <int> Q;
vector <int> Y;
int n,i,j;
string s;
vector <int> pr;
int R[30];

int A[2000] = {0};

int main()
{
     cin >> s;
     n = s.size();
     FOR(i,2,n+1)
      if (prost(i)) pr.pb(i);

     memset(R,0,sizeof(R));

     FOR(i,0,s.size())
       ++R[s[i]-'a'];

     if (pr.size()<2)
      {
       cout<<"YES"<<endl;
       cout<<s<<endl;
      }
     else
      {
         int NW = 0;
         FOR(i,1,pr.size())
           if (pr[i]*2>n)
            {
             NW = i;
             break;
            }
         if (NW == 0)
          {
            FOR(i,0,26)
               if (R[i])
                {
                 Q.pb(R[i]);
                 Y.pb(i);
                }

            if (Q.size()>2) cout << "NO" << endl;
             else
              {
               FOR(i,0,Q.size())
                FOR(j,i+1,Q.size())
                  if (Q[i] < Q[j])
                   {
                     swap(Q[i],Q[j]);
                     swap(Y[i],Y[j]);
                   }
               if (Q[0] < n-1) cout << "NO" << endl;
                else
                 {
                  if (Q.size() == 1)
                   {
                    cout << "YES" << endl;
                    FOR(i,0,s.size())
                      cout << (char)(Y[0]+'a');
                    cout << endl;
                   }
                  else
                   {
                    cout << "YES" << endl;
                    cout << (char)(Y[1]+'a');
                    FOR(i,1,s.size())
                        cout << (char)(Y[0]+'a');
                    cout << endl;
                   }
                 }
              }
          }
         else
          {
             FOR(i,0,26)
               if (R[i])
                {
                 Q.pb(R[i]);
                 Y.pb(i);
                }

             FOR(i,0,Q.size())
              FOR(j,i+1,Q.size())
               if (Q[i] < Q[j])
                {
                 swap(Q[i],Q[j]);
                 swap(Y[i],Y[j]);
                }

             FOR(i,0,n)
               if (i%2 == 1)
                 {
                   if (Q[0] == 0)
                    {
                     cout << "NO" << endl;
                     exit(0);
                    }
                   else
                    {
                     A[i] = Y[0];
                     --Q[0];
                    }
                 }
             FOR(i,1,NW)
                   if (Q[0] == 0)
                     {
                       cout << "NO" << endl;
                       exit(0);
                     }
                   else
                    {
                     Q[0]--;
                     A[pr[i]-1] = Y[0];
                    }

             FOR(i,NW,pr.size())
                {
                 FOR(j,0,Q.size())
                   if (Q[j])
                    {
                        Q[j]--;
                        A[pr[i]-1] = Y[j];
                        break;
                    }
                }
             FOR(i,0,Q.size())
               if (Q[i])
                {
                 A[0] = Y[i];
                 break;
                }

             cout << "YES" << endl;
             FOR(i,0,n)
               cout << (char)('a'+A[i]);
             cout << endl;
          }
      }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <cmath>
#include <string>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for ((i) = (a); i < (b); ++i)
#define inf 1000000000

bool prost(int x)
 {
    if (x<2) return false;
    else
     {
      int i;
      for (i = 2; i * i <= x; ++i)
         if (x%i == 0) return false;
      return true;

     }
 }

vector <int> Q;
vector <int> Y;
int n,i,j;
string s;
vector <int> pr;
int R[30];

int A[2000] = {0};

int main()
{
     cin >> s;
     int k;
     n = s.size();
     FOR(i,0,n)
      A[i] = -1;
     FOR(i,2,n+1)
      if (prost(i)) pr.pb(i);

     memset(R,0,sizeof(R));

     FOR(i,0,s.size())
       ++R[s[i]-'a'];

     if (s.size() < 4) {
                        cout << "YES" << endl;
                        cout << s << endl;
                        exit(0);
                       }
          else
           {
            FOR(i,0,26)
              if (R[i])
               {
                Q.pb(R[i]);
                Y.pb(i);
               }

            FOR(i,0,Q.size())
             FOR(j,i+1,Q.size())
              if (Q[i] < Q[j])
               {
                k = Q[i]; Q[i] = Q[j]; Q[j] = k;
                k = Y[i]; Y[i] = Y[j]; Y[j] = k;
               }

            FOR(i,0,n)
             {
               j = i + 1;
               if (j%2 == 0)
                {
                 A[i] = Y[0];
                 if (Q[0] == 0)
                  {
                     cout << "NO" << endl;
                     exit(0);
                  }
                 else --Q[0];

                 if (A[i/2] == -1)
                  {
                   if (Q[0] == 0)
                    {
                     cout <<"NO" << endl;
                     exit(0);
                    }
                   else --Q[0];
                   A[i/2] = Y[0];
                  }

                }
             }
            FOR(i,0,n)
             if (A[i] == -1)
               {
                FOR(j,0,Q.size())
                  if (Q[j])
                   {
                    Q[j]--;
                    A[i] = Y[j];
                    break;
                   }
               }

            cout << "YES" << endl;
            FOR(i,0,n)
              cout << (char)('a' + A[i]);
            cout << endl;
           }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <cmath>
#include <string>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for ((i) = (a); i < (b); ++i)
#define inf 1000000000

bool prost(int x)
 {
      int i;
      bool ok = true;
      for (i = 2; i * i <= x; ++i)
         if (x % i == 0) {
                        ok = true;
                        break;
                       }
      return ok;
 }

vector <int> Q;
vector <int> Y;
int n,i,j;
string s;
vector <int> pr;
int R[200];

int A[2000] = {0};

int main()
{
     cin >> s;
     int k;
     n = s.size();
     FOR(i,0,n)
      A[i] = -1;
     FOR(i,2,n+1)
      if (prost(i)) pr.pb(i);

     memset(R,0,sizeof(R));

     FOR(i,0,n)
       ++R[s[i]-'a'];

            FOR(i,0,100)
              if (R[i])
               {
                Q.pb(R[i]);
                Y.pb(i);
               }

            FOR(i,0,Q.size())
             FOR(j,i+1,Q.size())
              if (Q[i] < Q[j])
               {
                k = Q[i]; Q[i] = Q[j]; Q[j] = k;
                k = Y[i]; Y[i] = Y[j]; Y[j] = k;
               }

            FOR(i,0,n)
             {
               j = i + 1;
               if (j%2 == 0)
                {
                 A[i] = Y[0];
                 if (Q[0] == 0)
                  {
                     cout << "NO" << endl;
                     exit(0);
                  }
                 else --Q[0];

                 if (j/2 != 1 && A[j/2-1] == -1)
                  {
                   if (Q[0] == 0)
                    {
                     cout <<"NO" << endl;
                     exit(0);
                    }
                   else --Q[0];
                   A[j/2-1] = Y[0];
                  }

                }
             }

            FOR(i,1,pr.size())
             if (pr[i]*2 <= n)
              {
                FOR(j,1,1000)
                  if (pr[i]*j <= n)
                   {
                               if (A[pr[i]*j-1] == -1)
                                {
                                 if (Q[0])
                                  {
                                      Q[0]--;
                                      A[pr[i]*j-1] = Y[0];
                                  }
                                 else
                                  {
                                   cout << "NO" << endl;
                                   exit(0);
                                  }
                                }
                   }
                  else break;
              }

            FOR(i,0,n)
             if (A[i] == -1)
               {
                FOR(j,0,Q.size())
                  if (Q[j])
                   {
                    Q[j]--;
                    A[i] = Y[j];
                    break;
                   }
               }

            cout << "YES" << endl;
            FOR(i,0,n)
              cout << (char)('a' + A[i]);
            cout << endl;
}