#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <unordered_map>

#define fst first
#define snd second
#define sz(v_) (int((v_).size()))

using namespace std;

typedef long long ll;

const int maxn = 7e5;
int m, n, l, ml;

string s;
pair<int, string> q[maxn];
long long d[maxn];
unordered_map<ll, int> ma;

const ll p = 5;
const ll mod = 100000000000000003;
bool a1 = 1;
ll ha[maxn];
ll pw[maxn];

void update(ll h, int v)
{
    if (ma.count(h) == 0) {
        ma[h] = v;
    } else {
        ma[h] = min(ma[h], v);
    }
}

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> m >> n >> l;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        cin >> q[i].fst >> q[i].snd;
        if (q[i].fst != 1) {
            a1 = 0;
        }
        ll cur = 1;
        ll h = 0;
        for (int w = sz(q[i].snd)-1; w >= 0; --w) {
            h += (q[i].snd[w]-'0'+1)*cur;
            h %= mod;
            cur = (cur*p)%mod;
            update(h, q[i].fst);
        }
        h = 0;
        for (int w = 0; w < sz(q[i].snd); ++w) {
            h *= p;
            h += (q[i].snd[w]-'0'+1);
            h %= mod;
            update(h, q[i].fst);
        }
        ml = max(ml, sz(q[i].snd));
    }
    pw[0] = 1;
    for (int i = 1; i < maxn; ++i) {
        pw[i] = (pw[i-1]*p)%mod;
    }
#define HASH(l_) ((__int128(ha[i])+__int128(mod)*__int128(mod)-__int128(ha[i-(l_)])*__int128(pw[l_]))%__int128(mod))
    ha[0]= 0;
    for (int i = 1; i <= m; ++i) {
        ha[i] = (ha[i-1]*p+s[i-1]-'0'+1)%mod;
        d[i] = 1e18;
        //cout << "---" << endl;
        if (a1) {
            int lb = 0, rb = min(i, ml)+1, mb;
            while (rb-lb > 1) {
                mb = (lb+rb)/2;
                if (ma.count(HASH(mb)) > 0) {
                    lb = mb;
                } else {
                    rb = mb;
                }
            }
            if (lb > 0) {
                d[i] = min(d[i], d[i-lb]+1);
            }
            //cout << lb << endl;
        } else {
            for (int le = 1; le <= min(i, ml); ++le) {
                ll h = HASH(le);
                if (ma.count(h) > 0) {
                    //cout << le << ' ';
                    d[i] = min(d[i], d[i-le]+ma[h]);
                }
            }
            //cout << endl;
        }
    }
    cout << (d[m] == 1e18 ? -1 : d[m]) << '\n';
    return 0;
}
