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

public class TypingWithThreads {
    private String fileName = "typing";

    HashMap<Long, Integer> sub;
    int m, n, l, count;
    long[] deg3, hash;
    int[] c;
    char[][] s;

    public void solve() throws IOException {
        m = nextInt();
        n = nextInt();
        l = nextInt();

        char[] str = nextToken().toCharArray();
        hash = new long[m + 1];
        hash[0] = 0;
        for (int i = 0; i < m; i++) {
            hash[i + 1] = hash[i] * 3 + (str[i] - '0' + 1);
        }

        deg3 = new long[Math.max(l, m) + 1];
        deg3[0] = 1;
        for (int i = 1; i <= Math.max(l, m); i++) {
            deg3[i] = deg3[i - 1] * 3;
        }

        sub = new HashMap<>();
        s = new char[n][];
        c = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = nextInt();
            s[i] = nextToken().toCharArray();
            new Thread(new StringThread(i)).start();
        }

        while (count < n);
        if (count == n) {
            long[] res = new long[m + 1];
            Arrays.fill(res, Long.MAX_VALUE);
            res[0] = 0;
            for (int i = 0; i < m; i++) {
                for (int j = 0; j <= i; j++) {
                    long h = hash[i + 1] - hash[j] * deg3[i - j + 1];
                    if (sub.containsKey(h)) {
                        res[i + 1] = Math.min(res[i + 1], res[j] + sub.get(h));
                    }
                }
            }
            out.println(res[m] == Long.MAX_VALUE ? -1 : res[m]);
        } else {
            out.println(-1);
        }
    }

    private class StringThread extends Thread {
        int r;

        public StringThread(int r) {
            this.r = r;
        }

        public void run() {
            long h = 0;
            for (int t = 0; t < s[r].length; t++) {
                h = h * 3 + (s[r][t] - '0' + 1);
                if (sub.containsKey(h)) {
                    sub.put(h, Math.min(sub.get(h), c[r]));
                } else {
                    sub.put(h, c[r]);
                }
            }
            for (int t = 0; t < s[r].length - 1; t++) {
                h = h - (s[r][t] - '0' + 1) * deg3[s[r].length - t - 1];
                if (sub.containsKey(h)) {
                    sub.put(h, Math.min(sub.get(h), c[r]));
                } else {
                    sub.put(h, c[r]);
                }
            }
            count++;
        }
    }

    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 TypingWithThreads().run();
    }

}