#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int INF = 1e9+1;
const LL LLINF = 1e17;

struct Trie {
    struct Node {
        int p[2];
        int c;
        void init() {
            p[0] = p[1] = -1;
            c = INF;
        }
        void remin(int nc) {
            if(c > nc) c = nc;
        }
    } __attribute__((packed));
    vector<Node> v;
    int nxt;
    Trie() : v(3e7), nxt(1) {
        v[0].init();
    }
    void ins(const char *s, int c, bool pref) {
        int p = 0;
        for(int i = 0; s[i]; ++i) {
            int val = s[i] - '0';
            if(v[p].p[val] == -1) {
                v[nxt].init();
                v[p].p[val] = nxt;
                ++nxt;
            }
            p = v[p].p[val];
            if(pref) {
                v[p].remin(c);
            }
        }
        if(!pref) {
            v[p].remin(c);
        }
    }
    void collect(const char *s, vector<int> &jump) {
        int p = 0;
        for(int i = 0; s[i]; ++i) {
            int val = s[i] - '0';
            if((p = v[p].p[val]) == -1) {
                break;
            }
            jump[i+1] = v[p].c;
        }
    }
};

inline void remin(LL &a, LL b) { if(a > b) a=b; }

int main() {
    #define FNAME "typing"
    #ifndef LOCAL
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
    #endif
    int m, n, l;
    scanf("%d%d%d", &m, &n, &l);
    char *s = (char*)malloc(m+1);
    char *buf = (char*)malloc(l+1);
    scanf("%s", s);
    Trie t;
    for(int i = 0; i < n; ++i) {
        int c;
        scanf("%d%s", &c, buf);
        t.ins(buf, c, true);
        for(int i = 1; buf[i]; ++i) {
            t.ins(buf+i, c, false);
        }
    }
    vector<int> jump;
    vector<LL> dp(m+1, LLINF);
    dp[m] = 0;
    for(int pref = m-1; pref >= 0; --pref) {
        jump.assign(m+1, INF);
        t.collect(s+pref, jump);
        int lim = m - pref;
        for(int i = 1; i <= lim; ++i) {
            if(jump[i] != INF) {
                remin(dp[pref], dp[pref+i] + jump[i]);
            }
        }
    }
    printf("%I64d", dp[0] == LLINF ? -1LL : dp[0]);
    return 0;
}
