#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>

using namespace std;

const int N = 5001;
int n, m, L, c[N], maxl;
int64_t ans[N];
string s, w[N];

const int64_t q = 1e4 + 3337, mod = 1e9 + 3337;
//vector<int64_t> wh[N][1001];
int64_t ph[N][1001], sh[N][1001];
int64_t h[N][N];

int64_t mpow(int b)
{
    int64_t cd = 1, cp = 0, c = q;
    for (int i = 0; (1 << i) <= b; ++i)
    {
        if ((1 << i) & b)
            cd *= c;
        (c *= c) %= mod;
    }
    return cd;
}

int main()
{
    ifstream cin("typing.in");
    ofstream cout("typing.out");
    cin >> m >> n >> L;
    cin >> s;
    for (int i = 0; i < n; ++i)
    {
        cin >> c[i] >> w[i];
//        for (int j = 0; j < w[i].size(); ++j)
//            wh[i][j].resize(w[i].size() + 2);
//        for (int j = 0; j < w[i].size(); ++j)
//        {
//            wh[i][j][0] = 0;
//            for (int l = 1; j + l <= w[i].size(); ++l)
//                wh[i][j][l] = (q * wh[i][j][l - 1] + w[i][j + l - 1]) % mod;
//
//        }
        ph[i][0] = 0;
        for (int j = 1; j <= w[i].size(); ++j)
            ph[i][j] = (q * ph[i][j - 1] + w[i][j - 1]) % mod;
        sh[i][0] = 0;
        for (int j = 1; j <= w[i].size(); ++j)
            sh[i][j] = (sh[i][j - 1] + mpow(j - 1) * w[i][w[i].size() - j]) % mod;
        maxl = max(maxl + 0ul, w[i].size());
    }
    for (int i = 0; i < s.size(); ++i)
    {
        h[i][0] = 0;
        for (int j = 1; i + j <= s.size() && j <= maxl; ++j)
            h[i][j] = (q * h[i][j - 1] + s[i + j - 1]) % mod;
    }
    memset(ans, 63, sizeof(ans));
    ans[0] = 0;
    for (int i = 1; i <= m; ++i)
        for (int k = 0; k < n; ++k)
            for (int j = 1; j <= i && j <= w[k].size(); ++j)
            {
                if (ph[k][j] == h[i - j][j])
//                if (wh[k][0][j] == h[i - j][j])
//                if (w[k].substr(0, j) == s.substr(i - j, j))
                    ans[i] = min(ans[i], ans[i - j] + c[k]);
                if (sh[k][j] == h[i - j][j])
//                if (wh[k][w[k].size() - j][j] == h[i - j][j])
//                if (w[k].substr(w[k].size() - j, j) == s.substr(i - j, j))
                    ans[i] = min(ans[i], ans[i - j] + c[k]);
            }
    cout << (ans[m] < 1e18? ans[m]: -1ll);
    return 0;
}
