#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 1;
const int INF = 2e9 + 1;
const int P1 = 3;
const ll MOD1 = 1e9 + 7;
const ll P2 = 29;
const ll MOD2 = 1e9 + 9;

int cost[N];
string st[N];
int d[N];

int main() {
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int m, n, l;
    cin >> m >> n >> l;
    string s;
    cin >> s;
    fr(i, n) {
        cin >> cost[i] >> st[i];
    }
    map <string, int> cst;

    fr(i, n) {
        fr(l, st[i].size())
            frab(r, l, st[i].size()) if (l == 0 || r + 1 == st[i].size()) {
                if (!cst.count(st[i].substr(l, r - l + 1)))
                    cst[st[i].substr(l, r - l + 1)] = cost[i];
                else
                    cst[st[i].substr(l, r - l + 1)] = min(cst[st[i].substr(l, r - l + 1)], cost[i]);
                //cout << st[i].substr(l, r - l + 1) << " " << cost[i] << endl;
            }
    }

    fill(d, d + m + 10, INF);
    d[0] = 0;
    fr(i, m) {
        fr(j, i + 1)
            if (cst.count(s.substr(j, i - j + 1)))
                d[i + 1] = min(d[i + 1], d[j] + cst[s.substr(j, i - j + 1)]);
    }
    if (d[m] == INF)
        cout << -1;
    else
        cout << d[m];

}
