#include <bits/stdc++.h>

#define int ll
#define ll long long

using namespace std;

const int INF = 1e17;

#undef int
int main() {
    #define int ll
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int m, n, L;
    string ans;
    cin >> m >> n >> L >> ans;
    vector<int> c(n);
    vector<string> w(n);
    for (int i = 0; i < n; ++i)
        cin >> c[i] >> w[i];
    vector<int> dp(m + 1, INF);
    dp[0] = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int cur = 0; cur < w[j].size() && i - cur - 1 >= 0 && ans[i - cur - 1] == w[j][cur]; ++cur) {
                if (dp[i - cur - 1] != INF)
                    dp[i] = min(dp[i], c[j] + dp[i - cur - 1]);
            }
            for (int cur = 0; cur < w[j].size() && i - cur - 1 >= 0 && ans[i - cur - 1] == w[j][w[j].size() - cur - 1]; ++cur) {
                if (dp[i - cur - 1] != INF)
                    dp[i] = min(dp[i], c[j] + dp[i - cur - 1]);
            }
        }
    }
    if (dp[m] == INF)
        cout << -1 << endl;
    else
        cout << dp[m] << endl;
    return 0;
}
