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

typedef pair < int , int > ipair;

struct Word
{
    int cost;
    string s;
} 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[N];

int main()
{
#ifndef LOCAL
    freopen(TASK".in", "r", stdin);
    freopen(TASK".out", "w", stdout);
#endif
    ios::sync_with_stdio(false);

    cin >> n >> m >> lll >> s;
    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; });

    for (int i = m - 1; i >= 0; --i)
    {
        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;
    for (int i = 1; i <= n; ++i)
    {
        int curr = 0;
        for (int j = i - 1; j >= 0; --j)
        {
            curr = borR[curr].e[s[j] - '0'];
            if (curr == -1)
                break;
            d[i] = min(d[i], d[j] + borR[curr].cost);
        }
        curr = 0;
        for (int j = i; j < n; ++j)
        {
            curr = bor[curr].e[s[j] - '0'];
            if (curr == -1)
                break;
            d[j + 1] = min(d[j + 1], d[i] + bor[curr].cost);
        }
    }
    if (d[n] >= 1000000000)
        throw 42;
    cout << (d[n] == LINF ? -1 : d[n]) << "\n";

    return 0;
}
