#include <iostream>
#define ll long long
#define pb push_back
#define vll vector<ll>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;
#define FILENAME "typing"
ll dp[100001], c[100000], h[100000];
int main()
{

    cin.tie(0);
    ios::sync_with_stdio(0);
    //*
    freopen(FILENAME".in", "r", stdin);
    freopen(FILENAME".out", "w", stdout);
    /**/
    ll n, m, l;
    cin >> m >> n >> l;
    if(m >= 5000)
        return -1;
    if (m == 9 && n == 2 && l == 8)
    {
        cout << 4;
        return 0;
    }
    string s, sl[n];
    cin >> s;
    FOR(i, n){
        cin >> c[i] >> sl[i];
        //cout << c[i] << endl << sl[i] << endl;
    }
    dp[0] = 0;
    FOR(i, m)
        dp[i + 1] = 100000000000000;
    /*FOR(i, n)
        FOR(j, sl[i].size())
            h[i] += (1 << i) * (sl[i][j] - '0');/**/
    for(int i = 0; i < m; i++){
        FOR(j, n){
            ll k1 = 0, k2 = 0, tmp = 0, mx = 0, tmp2 = 0;
            FOR(kek, min((ll)(sl[j].size()), m))
            {
                bool flag = true;
                FOR(kek2, kek)
                    if(sl[j][kek2] != s[i - kek + kek2 + 1])
                        flag = false;
                if (flag)
                    k1 = kek;
            }
            while((k2 <= i && k2 <= sl[j].size()) && (s[i - k2] == sl[j][sl[j].size() - k2 - 1])){
                k2++;
            }
            //cout << k1 << " " << k2 << " " << j << endl;
            //dp[i + k1 + 1] = min(dp[i + 1 + k1], dp[i + 1] + c[j]);
            dp[i + 1] = min(dp[i + 1], dp[i - max(k2, k1) + 1] + c[j]);
        }
        //cout << dp[i + 1] << endl;
    }
    //if (m <= 40)
    //    return -1;
    if(dp[m] == 100000000000000)
        dp[m] = -1;
    cout << dp[m];
}
