#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ll;

const ll INF = 1e18;
const int maxn = 3e5 + 5;
const ll P = 17;
ll power[maxn];

int m, n, L;
unordered_map<ll, int> cost;
ll d[maxn];

void get(const string &s, int p) {
    d[p] = INF;
    ll hash = 0;
    for (int i = p; i < min(p + 2005, m); i++) {
        ll c = s[i] - '0';
        hash = hash * P + c + 1;
        if (cost.find(hash) != cost.end()) {
            d[p] = min(d[p], d[i + 1] + cost[hash]);
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);

    power[0] = 1;
    for (int i = 1; i < maxn; i++) power[i] = power[i - 1] * P;
    cost.rehash(maxn);

    cin >> m >> n >> L;
    string str;
    cin >> str;
    for (int i = 0; i < n; i++) {
        int w; string t;
        cin >> w >> t;
        ll hash = 0;
        for (int j = 0; j < t.size(); j++) {
            ll c = t[j] - '0';
            hash = hash * P + c + 1;
            if (cost.find(hash) == cost.end() || cost[hash] > w) cost[hash] = w;
        }
        for (int j = 0; j < t.size(); j++) {
            ll c = t[j] - '0';
            hash -= (c + 1) * power[t.size() - j - 1];
            if (cost.find(hash) == cost.end() || cost[hash] > w) cost[hash] = w;
        }
    }

    for (int i = m - 1; i >= 0; i--) {
        get(str, i);
    }

    if (d[0] == INF) cout << -1 << '\n';
    else cout << d[0] << '\n';
}
