#include <bits/stdc++.h>

using namespace std;

void sol(int m, int n, int L)
{
    string s;
    cin >> s;
    int ans[m + 1];
    ans[0] = 0;
    string dn[n];
    int c[n];
    for (int i = 0; i < n; ++i)
        cin >> c[i] >> dn[i];
    for (int i = 1; i <= m; ++i)
    {
        ans[i] = 1e9;
        for (int j = 0; j < m; ++j)
            for (int k = 0; k < n; ++k)
            {
                if (dn[k].length() >= i - j)
                {
                    bool fl = true;
                    for (int len = j; len < i; ++len)
                        if (dn[k][len - j] != s[len])
                            fl = false;
                    if (fl)
                        ans[i] = min(ans[i], ans[j] + c[k]);
                    fl = true;
                    for (int len = j; len < i; ++len)
                        if (dn[k][dn[k].length() - len + j - 1] != s[len])
                            fl = false;
                    if (fl)
                        ans[i] = min(ans[i], ans[j] + c[k]);
                }
            }
    }
    if (ans[m] == 1e9)
        printf("-1\n");
    else
        printf("%d\n", ans[m]);
}

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int n, m, L, dich;
    while (scanf("%d%d%d", &m, &n, &L) == 3)
        sol(m, n, L);
    return 0;
}
