#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
using namespace std;

#define INF 1791791791791791ll

int main()
{
#ifndef LOCAL
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
#endif
    int m, n, L;
    cin >> m >> n >> L;
    string s;
    cin >> s;
    vector<string> t(n); vector<ll> c(n);
    for (int i = 0; i < n; i++)
        cin >> c[i] >> t[i];
    vector<string> rev_t(n);
    for (int i = 0; i < n; i++)
    {
        rev_t[i] = t[i];
        reverse(rev_t[i].begin(), rev_t[i].end());
    }
    vector<vector<ll> > dp(m, vector<ll>(m, INF));
    for (int i = m - 1; i >= 0; i--)
    {
        for (int j = i; j < m; j++)
        {
            for (int k = 0; k < n; k++)
            {
                for (int p = 0; p < (int)t[k].size(); p++)
                {
                    if (s.substr(i, j - i + 1) == t[k].substr(0, p + 1) || s.substr(i, j - i + 1) == t[k].substr(t[k].size() - p - 1, p + 1))
                    {
                        dp[i][j] = min(dp[i][j], c[k]);
                    }
                }
            }
            for (int k = i; k < j; k++)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);
        }
    }
    if (dp[0][m - 1] == INF)
        cout << -1 << endl;
    else
        cout << dp[0][m - 1] << endl;
    return 0;
}
