#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int maxn = 300000;
const ll inf = (ll)1e18 + 1;
int n, m, L;
string s;
ll dp[maxn];
string w[maxn];
ll c[maxn];
int main() {
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "wt", stdout);
    cin >> m >> n >> L;
    cin >> s;
    for (int i = 0; i < n; ++i)
        cin >> c[i] >> w[i];
    dp[0] = 0;
    for (int i = 1; i <= m; ++i) {
        dp[i] = inf;
        for (int j = 0; j < n; ++j) {
            for (int k = 1; k <= min(i, (int)w[j].size()); ++k) {
                bool ok = true;
                for (int x = 0; x < k; ++x)
                    if (s[i - k + x] != w[j][x])
                        ok = false;
                if (ok)
                    dp[i] = min(dp[i], dp[i - k] + c[j]);
            }
            for (int k = 1; k <= min(i, (int)w[j].size()); ++k) {
                bool ok = true;
                for (int x = (int)w[j].size() - k; x < (int)w[j].size(); ++x)
                    if (s[i + x - (int)w[j].size() + k] != w[j][x])
                        ok = false;
                if (ok)
                    dp[i] = min(dp[i], dp[i - k] + c[j]);
            }
        }
    }

    if (dp[m] == inf)
        cout << "-1";
    else
        cout << dp[m];
    return 0;
}
/*
9 2 8
000110100
1 100
1 11001
*/
