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

typedef long long ll;
#define all(v) v.begin(), v.end()

const ll inf = 1e18;

ll cost[300007], d[300007];
vector<vector<int> > pf;
vector<string> ex;

vector<int> mp(string s){
    vector<int> p;
    p.resize(s.size());
    p[0] = 0;
    for (int i = 1; i < s.size(); i++){
        int j = p[i - 1];
        while (j != 0 && s[j] != s[i]){
            j = p[j - 1];
        }
        if (s[i] == s[j]){
            j++;
        }
        p[i] = j;
    }
    return p;
}

int main(){
    //freopen("input.txt", "r", stdin);
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int n, m, l;
    cin >> m >> n >> l;
    string ob;
    cin >> ob;
    pf.resize(n);
    ex.resize(n);
    for (int i = 0; i < n; i++){
        int t;
        cin >> t;
        cost[i] = t;
        cin >> ex[i];
        pf[i] = mp(ex[i] + "#" + ob);

    }
    d[0] = 0;
    for (int i = 1; i <= m; i++){
        d[i] = inf;
        for (int j = 0; j < n; j++){
            int sd = ex[j].size();
            for (int k = 0; k < sd; k++){
                int ind = (i - 1) - k;
                char ts = '#';
                if (ind >= 0){
                    ts = ob[ind];
                }
                if (ts != ex[j][sd - 1 - k]){
                    break;
                }
                d[i] = min(d[i], d[i - (k + 1)] + cost[j]);
            }

            int q = pf[j][sd + i];
            while (q > 0){
                d[i] = min(d[i], d[i - q] + cost[j]);
                q = pf[j][q - 1];
            }
        }
        //cout << d[i] << " ";
    }
    if (d[m] == inf){
        cout << -1;
    } else {
        cout << d[m];
    }
    return 0;
}

