/**
 * Created by roi on 07.04.2016.
 */
import java.io.*;
import java.util.*;

public class D {
    String fileName = "typing";

    public void solve() throws IOException {
        // write your code here
        int m = nextInt(); // dlina stroki
        int n = nextInt();  // slov chislo
        int l = nextInt();   // summa dlin
        String S = nextToken();
        char[] st = S.toCharArray();
        int[] str = new int[m];
        for (int i = 0; i < m; i++){
            if (st[i] == '0'){
                str[i] = 0;
            }
            else{
                str[i] = 1;
            }
        }
        long[] c = new long[n];   // cost
        char[] co;
        ArrayList<Integer>[] t = new ArrayList[n];   // stroki melkie
        for (int i = 0; i < n; i++){
            t[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < n; i++) {
            c[i] = nextInt();
            S = nextToken();
            co = S.toCharArray();
            for (int j = 0; j < co.length; j++){
                if (co[j] == '0'){
                    t[i].add(0);
                }
                else{
                    t[i].add(1);
                }
            }
        }
        long[] dyn = new long[m];
        for (int i = 0; i < m; i++){
            dyn[i] = Long.MAX_VALUE;
        }
        boolean bo1;
        boolean bo2;
        for (int i = 0; i < m; i++){
            for (int j = 0; j <= i; j++){
                for (int k = 0; k < n; k++){
                    if (t[k].size() >= (i - j + 1)){
                        bo1 = true;
                        for (int u = 0; u <= (i - j); u++){
                            if (((int)t[k].get(u)) != str[j + u]){
                                bo1 = false;
                            }
                        }
                        bo2 = true;
                        for (int u = t[k].size() - (i - j) - 1; u < t[k].size(); u++){
                            if (t[k].get(u) != str[j + u - ( t[k].size() - (i - j) - 1)]){
                                bo2 = false;
                            }
                        }
                        if (bo1 || bo2){
                            if (j == 0){
                                dyn[i] = Math.min(dyn[i], c[k]);
                            }
                            else{
                                dyn[i] = Math.min(dyn[i], dyn[j - 1] + c[k]);
                            }
                        }
                    }
                }
            }
        }
        out.print(dyn[m - 1]);
        out.close();
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader(fileName + ".in"));
            out = new PrintWriter(fileName + ".out");

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

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

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

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

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

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new D().run();
    }

}