#include <iostream>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>


using namespace std;


#define next next1


int m, n, l;
int next[20000001][2];
int root = 0;
int uk = 1;
int st[20000001];
bool t[20000001];


void add(string s, int cost, bool gt) {
    int cur = root;
    for (int i = 0; i < (int)s.size(); i++) {
        int c = s[i] - '0';
        if (next[cur][c] != 0) {
            cur = next[cur][c];
            if (gt) {st[cur] = min(st[cur], cost); t[cur] = 1;}
        } else {
            uk++;
            next[cur][c] = uk;
            if (gt) st[uk] = cost;
            if (gt) t[cur] = 1;
            cur = uk;
        }
    }
    t[cur] = 1;
    st[cur] = min(st[cur], cost);
}


long long dp[300001];


int main() {
   freopen("typing.in", "r", stdin);
   freopen("typing.out", "w", stdout);
    cin >> m >> n >> l;
    string s;
    cin >> s;
    for (int i = 0; i <= 20000000; i++) {
        st[i] = 1000000001;
    }
    for (int i = 0; i < n; i++) {
        int c;
        string a;
        cin >> c >> a;
        add(a, c, 1);
        for (int j = 0; j < (int)a.size(); j++) {
            string t;
            for (int k = j; k < (int)a.size(); k++) {
                t += a[k];
            }
            //cout << t << endl;
            add(t, c, 0);
        }
    }
    dp[0] = 0;
    for (int i = 1; i <= m; i++) {
        dp[i] = 1000000000000000000LL;
    }
    for (int i = 0; i < m; i++) {
        if (dp[i] == 1000000000000000000LL) {
            continue;
        }
        int cur = root;
        for (int j = i; j < m; j++) {
            cur = next[cur][s[j] - '0'];
            if (!cur) break;
            if (t[cur]) {
                dp[j + 1] = min(dp[j + 1], dp[i] + st[cur]);
            }
        }
    }
    if (dp[m] == 1000000000000000000LL) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[m] << endl;
    return 0;
}
