#include <bits/stdc++.h>

//#define int long long
#define f first
#define s second
#define all(a) (a).begin(), (a).end()
#define len(a) (int)(a).size()
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define endl '\n'

using namespace std;

long long INF = 1e13 + 37;
int M = 1e8 + 7;
int b = 3;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int m, n, l;
    cin >> m >> n >> l;
    string z;
    cin >> z;
    vector<long long> d(m + 1, INF);
    d[0] = 0LL;
    vector<pair<int, string> > q(n);
    forn(i, n) {
        cin >> q[i].f >> q[i].s;
    }
    vector<int> p(l, 1);
    for (int i = 1; i < l; ++i) {
        p[i] = (p[i - 1] * b) % M;
    }
    for (int i = 1; i <= m; ++i) {
        long long ans = INF;
        for (int j = 0; j < n; ++j) {
            string s = q[j].s;
            int c = q[j].f;
            int h1 = 0, h2 = 0, h3 = 0;
            for (int k = 1; k <= min(i, len(s)); ++k) {
                h1 = ((z[i - k] - '0' + 1) * p[k - 1] + h1) % M;
                h2 = (h2 * b + s[k - 1] - '0' + 1) % M;
                h3 = ((s[len(s) - k] - '0' + 1) * p[k - 1] + h3) % M;
                if (h1 == h2 || h1 == h3) {
                    ans = min(ans, c + d[i - k]);
                }
            }
        }
        d[i] = ans;
    }
    if (d[m] == INF) {
        cout << -1;
        return 0;
    }
    cout << d[m];
    return 0;
}
