#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18, lmax = 1000, p = 3, mod = (1ll<<60);
string s;
long long m;
vector<long long> dp;
map<long long, long long> 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;
    long long h = 0;
    for(int i = k; i < min(k+lmax, m); i++){
        h = (h*p + s[i]-'0'+1) % mod;
        //cerr << "try " << k << " " << i << " using " << t << endl;
        if(a.count(h))
            dp[k] = min(dp[k], f(i+1) + a[h]);
    }
    //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++){
        long long c;
        string t;
        cin >> c >> t;
        long long h = 0;
        for(size_t i = 0; i < t.size(); i++){
            h = (h*p + t[i]-'0'+1) % mod;
            if(a.count(h))
                a[h] = min(a[h], c);
            else
                a[h] = c;
        }
        h = 0;
        long long mul = 1;
        for(int i = t.size()-1; i >= 0; i--){
            h = ( h + mul*(t[i]-'0'+1) ) % mod;
            mul = mul*p % mod;
            if(a.count(h))
                a[h] = min(a[h], c);
            else
                a[h] = c;
        }
    }

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

    return 0;
}
