#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;

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

const ll p = 5;
const ll mod = 1e9+7;

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;
        for (int z = 0; z < sz(q[i].snd); ++z) {
            ll cur = 1;
            ll h = 0;
            for (int w = z; w < sz(q[i].snd); ++w) {
                h += (q[i].snd[w]-'0'+1)*cur;
                h %= mod;
                cur = (cur*p)%mod;
                if (z == 0) {
                    update(h, q[i].fst);
                }
            }
            update(h, q[i].fst);
        }
    }
    //sort(q, q+n);
    string tmp;
    for (int i = 1; i <= m; ++i) {
        d[i] = 1e18;
        ll h = 0;
        for (int le = 1; le <= i; ++le) {
            h += (s[i-le]-'0'+1);
            if (ma.count(h) > 0) {
                d[i] = min(d[i], d[i-le]+ma[h]);
            }
            h *= p;
            h %= mod;
        }
    }
    cout << (d[m] == 1e18 ? -1 : d[m]) << '\n';
    return 0;
}
