#include <bits/stdc++.h>

using namespace std;

map<string, int> m;
vector<pair<int, string>> v;
string s;
const int MX = 2e+9;
int mincost = MX;


void gen(int i, int cost) {
    if (i == s.size()) {
        mincost = min(cost, mincost);
        return;
    }
    for (auto j : v) {
        int cnt = 0;
        while (cnt < j.second.size() and i + cnt < s.size() and j.second[cnt] == s[i + cnt]) {
            ++cnt;
        }
        if (cnt == j.second.size()) {
            gen(i + cnt, cost + j.first);
        }
    }
}


int main() {
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);


    int szsz, n, l;
    cin >> szsz >> n >> l;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        int cost;
        cin >> cost;
        string t;
        cin >> t;
        string pref;
        for (int j = 0; j < t.size(); ++j) {
            pref += t[j];
            if (m[pref]) {
                m[pref] = min(m[pref], cost);
            } else {
                m[pref] = cost;
            }
        }
        for (int j = 1; j < t.size(); ++j) {
            string suf;
            for (int k = j; k < t.size(); ++k) {
                suf += t[k];
            }
            if (m[suf]) {
                m[suf] = min(m[suf], cost);
            } else {
                m[suf] = cost;
            }
        }
    }
    for (auto i : m) {
        v.push_back({i.second, i.first});
    }
    sort(v.begin(), v.end());

    gen(0, 0);

    if (mincost == MX) {
        cout << -1;
    } else {
        cout << mincost;
    }
}
