#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; i++)
#define frab(i, a, b) for (ll 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 ll N = 1e5 + 1;
const ll INF = 2e9 + 1;
const ll P1 = 257;
const ll MOD1 = 1e9 + 7;
const ll P2 = 29;
const ll MOD2 = 1e9 + 9;

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

ll hs1[N], hs2[N], p1[N], p2[N];

ll Hash1(ll l, ll r) {
    ll tmp = (hs1[r + 1] - hs1[l] * p1[r - l + 1]) % MOD1;
    if (tmp < 0) tmp += MOD1;
    return tmp;
}

ll Hash2(ll l, ll r) {
    ll tmp = (hs2[r + 1] - hs2[l] * p2[r - l + 1]) % MOD2;
    if (tmp < 0) tmp += MOD2;
    return tmp;
}

int main() {
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll m, n, l;
    cin >> m >> n >> l;
    string s;
    cin >> s;
    ll mx = 0;
    fr(i, n) {
        cin >> cost[i] >> st[i];
        mx = max(mx, st[i].size());
    }

    p1[0] = p2[0] = 1;
    frab(i, 1, m + 10)
        p1[i] = (p1[i - 1] * P1) % MOD1, p2[i] = (p2[i - 1] * P2) % MOD2;
    fr(i, m) {
        hs1[i + 1] = (hs1[i] * P1 + s[i] - '0' + 1) % MOD1;
        hs2[i + 1] = (hs2[i] * P2 + s[i] - '0' + 1) % MOD2;
    }

    map <pair <ll, ll>, ll> cst;

    fr(i, n) {
        ll h1 = 0, h2 = 0;
        fr(j, st[i].size()) {
            h1 = (h1 * P1 + st[i][j] - '0' + 1) % MOD1;
            h2 = (h2 * P2 + st[i][j] - '0' + 1) % MOD2;
            if (!cst.count(mp(h1, h2)))
                cst[mp(h1, h2)] = cost[i];
            else
                cst[mp(h1, h2)] = min(cst[mp(h1, h2)], cost[i]);
        }
        h1 = 0, h2 = 0;
        for (ll j = (ll)st[i].size() - 1; j >= 0; j--) {
            h1 = (h1 + (st[i][j] - '0' + 1) * p1[(ll)st[i].size() - j - 1]) % MOD1;
            h2 = (h2 + (st[i][j] - '0' + 1) * p2[(ll)st[i].size() - j - 1]) % MOD2;
            if (!cst.count(mp(h1, h2)))
                cst[mp(h1, h2)] = cost[i];
            else
                cst[mp(h1, h2)] = min(cst[mp(h1, h2)], cost[i]);
        }
    }

    fill(d, d + m + 10, INF);
    d[0] = 0;
    fr(i, m) {
        frab(j, max(0, i + 1 - mx), i + 1) {
            ll tmp1 = Hash1(j, i);
            ll tmp2 = Hash2(j, i);
            if (cst.count(mp(tmp1, tmp2))) {
                d[i + 1] = min(d[i + 1], d[j] + cst[mp(tmp1, tmp2)]);
            }
        }

    }
    if (d[m] == INF)
        cout << -1;
    else
        cout << d[m];

}
