#include <bits/stdc++.h>
#define TASK "typing"
 
#define sz(x) ((int)((x).size()))
 
using namespace std;
 
typedef long long ll;
 
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1 << 19;
const int D = 19;
const int Q = 4017;
const int MOD = 1000000007;
const int P = 179;
 
typedef pair < int , int > ipair;
 
struct Word
{
    int cost;
    string s;
    vector < int > h;
} w[N];
 
struct Node
{
    int cost = IINF;
    int e[2] = {-1, -1};
};
Node bor[N], borR[N];
int borSize = 1, borRSize = 1;
 
string s;
int n, m, lll;
ll d[D][N];
int h[N];
int qgp;
int ppow[N];
int stlen[N];

ll stGetMin(int l, int r)
{
    if (l > r)
        return LINF;
    int len = r - l + 1;
    int ss = stlen[len];
    return min(d[ss][l], d[ss][r - (1 << ss) + 1]);
}

inline int getHash(const int * h, int pos, int len)
{
    int hh = (h[pos + len] - 1LL*ppow[len]*h[pos]) % MOD;
    if (hh < 0)
        return hh + MOD;
    return hh;
}
 
int main()
{
#ifndef LOCAL
    freopen(TASK".in", "r", stdin);
    freopen(TASK".out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    for (int i = 1; i < N; ++i)
        for (int j = D - 1; j >= 0; --j)
            if (i >= (1 << j))
            {
                stlen[i] = j;
                break;
            }
 
    cin >> n >> m >> lll >> s;
    ppow[0] = 1;
    for (int i = 1; i < N; ++i)
        ppow[i] = (1LL * ppow[i - 1] * P) % MOD;

    h[0] = 0;
    for (int i = 0; i < n; ++i)
        h[i + 1] = (1LL * h[i] * P + s[i]) % MOD;

    for (int i = 0; i < m; ++i)
        cin >> w[i].cost >> w[i].s;
    sort(w, w + m, [](const Word & a, const Word & b) { return a.cost < b.cost; });
 
    qgp = m;
    for (int i = m - 1; i >= 0; --i)
    {
        w[i].h.push_back(0);
        for (int j = 0; j < sz(w[i].s); ++j)
            w[i].h.push_back((1LL*w[i].h.back()*P + w[i].s[j]) % MOD);
        if (sz(w[i].s) > Q)
        {
            qgp = i;
            continue;
        }
        int curr = 0;
        for (int j = 0; j < sz(w[i].s); ++j)
        {
            int c = w[i].s[j] - '0';
            int & e = bor[curr].e[c];
            if (e == -1)
                e = borSize++;
            curr = e;
            bor[curr].cost = w[i].cost;
        }
        curr = 0;
        for (int j = sz(w[i].s) - 1; j >= 0; --j)
        {
            int c = w[i].s[j] - '0';
            int & e = borR[curr].e[c];
            if (e == -1)
                e = borRSize++;
            curr = e;
            borR[curr].cost = w[i].cost;
        }
    }
    bor[0].cost = 0;
    borR[0].cost = 0;
 
    memset(d, 0x3f, sizeof(d));
    d[0][0] = 0;
    multiset < ll > ssmin;
    static vector < ll > rsm[N];
    for (int i = 0; i <= n; ++i)
    {
        for (ll x : rsm[i])
            ssmin.erase(ssmin.find(x));
        if (!ssmin.empty())
            d[0][i] = min(d[0][i], *ssmin.begin());
        int curr = 0;
        for (int j = i - 1; j >= 0; --j)
        {
            curr = borR[curr].e[s[j] - '0'];
            if (curr == -1)
                break;
            d[0][i] = min(d[0][i], d[0][j] + borR[curr].cost);
        }
        for (int j = qgp; j < m; ++j)
        {
            const Word & word = w[j];
            int l = 0, r = min(i, sz(w[j].s));
            while (l < r)
            {
                int mid = (l + r + 1) / 2;
                if (getHash(h, i - mid, mid) == getHash(w[j].h.data(), sz(w[j].s) - mid, mid))
                    l = mid;
                else
                    r = mid - 1;
            }
            d[0][i] = min(d[0][i], stGetMin(i - l, i - 1) + w[j].cost);
        }

        for (int v = 1; v < D; ++v)
        {
            int rr = i - (1 << v) + 1;
            if (rr >= 0)
                d[v][rr] = min(d[v-1][rr], d[v-1][rr+(1<<(v-1))]);
        }

        curr = 0;
        for (int j = i; j < n; ++j)
        {
            curr = bor[curr].e[s[j] - '0'];
            if (curr == -1)
                break;
            d[0][j + 1] = min(d[0][j + 1], d[0][i] + bor[curr].cost);
        }
        for (int j = qgp; j < m; ++j)
        {
            const Word & word = w[j];
            int l = 0, r = min(n - i, sz(w[j].s));
            while (l < r)
            {
                int mid = (l + r + 1) / 2;
                if (getHash(h, i, mid) == getHash(w[j].h.data(), 0, mid))
                    l = mid;
                else
                    r = mid - 1;
            }
            ssmin.insert(d[0][i] + w[j].cost);
            rsm[i + l + 1].push_back(d[0][i] + w[j].cost);
        }
    }
    cout << (d[0][n] == LINF ? -1 : d[0][n]) << "\n";
 
    return 0;
}
