#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18, lmax = 50;
string s;
long long m;
vector<long long> dp;
map<string, int> a;

long long f(int k){
    //cerr << "rec " << k << endl;
    if(k == m)
        return 0;
    if(dp[k] != -1)
        return dp[k];
    dp[k] = inf;
    string t = "";
    for(int i = k; i < min(k+lmax, m); i++){
        t += s[i];
        //cerr << "try " << k << " " << i << " using " << t << endl;
        if(a.count(t))
            dp[k] = min(dp[k], f(i+1) + a[t]);
    }
    //cerr << k << " " << dp[k] << endl;
    return dp[k];
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("typing.in", "r", stdin);
    //freopen("typing.out", "w", stdout);

    int n, L;
    cin >> m >> n >> L;
    dp.assign(m, -1);

    cin >> s;

    for(int i = 0; i < n; i++){
        int c;
        string t;
        cin >> c >> t;
        string pref = "";
        for(size_t i = 0; i < t.size(); i++){
            pref += t[i];
            if(a.count(pref))
                a[pref] = min(a[pref], c);
            else
                a[pref] = c;
        }
        reverse(t.begin(), t.end());
        string suff = "";
        for(size_t i = 0; i < t.size(); i++){
            suff += t[i];
            if(a.count(suff))
                a[suff] = min(a[suff], c);
            else
                a[suff] = c;
        }
    }

    if(f(0) == inf)
        cout << -1 << endl;
    else
        cout << f(0) << endl;

    return 0;
}
