#include <bits/stdc++.h>

#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define NAME "typing"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define INF LLONG_MAX

using namespace std;

const int N = 50001;

int n, m, L, i, j, maxotr[N][N / 10], nx;
ll c[N], dp[N];
string s, a[N];
vector <int> z;

void z_f(int x) {
    string s1 = a[x] + '&' + s;
    //cout << s1 << endl;
    z.clear();
    z.resize(s1.size());
    int l = 0, r = 0;
    //cout << '0' << endl;
    for (int i = 1; i < s1.size(); i++) {
        if (i <= r)
            z[i] = min(r - i + 1, z[i - l]);
        while (i + z[i] < s1.size() && s1[i + z[i]] == s1[z[i]])
            z[i]++;
        if (i + z[i] - 1 > r) {
            l = i;
            r = i + z[i] - 1;
        }
        //cout << z[i] << endl;
    }
    for (int i = a[x].size() + 1; i < s1.size(); i++)
        maxotr[i - (a[x].size() + 1)][x] = max(maxotr[i - (a[x].size() + 1)][x], z[i]);
    //cout << endl;

}

int main()
{
    FREOPEN
    ios_base::sync_with_stdio(0);
    cin >> m >> n >> L;
    cin >> s;
    for (i = 0; i < n; i++) {
        cin >> c[i];
        cin >> a[i];
    }
    /*for (i = 0; i < m; i++)
        for (j = 0; j < n; j++) {
            maxotr[i][j] = z_f(i, j);
            reverse(a[j].begin(), a[j].end());
            maxotr[i][j] = max(maxotr[i][j], z_f(i, j));
            //cout << i << ' ' << j << ' ' << maxotr[i][j] << endl;
        }*/
    for (i = 0; i < n; i++) {
        z_f(i);
        reverse(a[i].begin(), a[i].end());
        z_f(i);
    }
    /*for (i = 0; i < m; i++)
        for (j = 0; j < n; j++)
            cout << i << ' ' << j << ' ' << maxotr[i][j] << endl;*/
    fill(dp, dp + N, INF);
    dp[0] = 0;
    for (i = 0; i < m; i++) {
        if (dp[i] == INF)
            continue;
        for (j = 0; j < n; j++) {
            nx = min(m, i + maxotr[i][j]);
            dp[nx] = min(dp[nx], dp[i] + c[j]);
        }
    }
    if (dp[m] == INF)
        return cout << -1, 0;
    cout << dp[m];
    return 0;
}













