#include <iostream>
#include <stdio.h>
#include <set>
#include <vector>
#include <string>

using namespace std;

int main() {
    freopen("video.in", "r", stdin);
    freopen("video.out", "w", stdout);
    int m, n, L;
    cin >> m >> n >> L;
    string s;
    cin >> s;
    pair<int, string> a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    int dp[s.size() + 1];
    dp[0] = 0;
    //cout << s.size();
    s = "#" + s;
    for (int i = 1; i < s.size(); i++) {
        dp[i] = 1000000;
        for (int k = 0; k < n; k++) {
            int q = i;
            int p = a[k].second.size() - 1;
            while (a[k].second[p] == s[q] && q >= 0 && p >= 0) {
                dp[i] = min(dp[i], dp[q - 1] + a[k].first);
                q--;
                p--;
            }
           // cout << "q:" << q << "k:" << k << endl;
            if (q >= 0) dp[i] = min(dp[i], dp[q] + a[k].first);
            for (int z = 0; z < a[k].second.size() && z < i; z++) {
                for (int c = z; c >= 0; c--) {
                    if (a[k].second[c] != s[i - c]) {
                        goto y;
                    }
                }
                dp[i] = min(dp[i], dp[i - z - 1] + a[k].first);
y:
                bool qwe;
            }
        }
        //cout << dp[i] << endl;
    }
    if (dp[s.size() - 1] == 1000000) {
        cout << -1;
        return 0;
    }
    cout << dp[s.size() - 1];
}
