#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;

const int INTINF = 1234567890;
const ll LLINF = 3e5 * 1e9 + 100;

const int N = 3e5;
const int X = 1e6;

int m, n, L;
string s;
int C[N];
string t[N];

int nxt[X][2];
int cost[X];
int tc;
int maxl;

ll dp[N + 1];

void clear() {
    memset(nxt, -1, sizeof nxt);
    fill(cost, cost + X, INTINF);
    cost[0] = 0;
    fill(dp, dp + m + 1, LLINF);
    dp[0] = 0;
    tc = 0;
    maxl = 0;
}

void add(string &f, int c) {
    int v = 0;
    for (int i = 0; i < (int)f.length(); i++) {
        int x = f[i] - '0';
        if (nxt[v][x] == -1) nxt[v][x] = ++tc;
        v = nxt[v][x];
        if (cost[v] > c) {
            cost[v] = c;
        }
    }
}

void solve_low_l() {
    s = "#" + s;
    for (int i = 0; i < n; i++) {
        add(t[i], C[i]);
        reverse(t[i].begin(), t[i].end());
        add(t[i], C[i]);
    }

    for (int i = 0; i <= m; i++) {
        string cur = "";
        for (int j = i + 1; j <= m; j++) {
            cur += s[j];
            for (int z = 0; z < n; z++) {
                if (t[z].substr(0, cur.length()) == cur) {
                    dp[j] = min(dp[j], dp[i] + C[z]);
                }
                reverse(t[z].begin(), t[z].end());
                if (t[z].substr(0, cur.length()) == cur) {
                    dp[j] = min(dp[j], dp[i] + C[z]);
                }
            }
        }
    }
/*
    for (int i = 0; i <= m; i++) {
        if (dp[i] == LLINF) continue;
        for (int j = i + 1, v = 0; j <= m; j++) {
            int x = s[j] - '0';
            v = nxt[v][x];
            if (v == -1) break;
            dp[j] = min(dp[j], dp[i] + cost[v]);
        }
    }*/

    if (dp[m] == LLINF) {
        puts("-1");
    } else {
        printf("%lld\n", dp[m]);
    }
}

int main() {
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);

    while (scanf("%d%d%d", &m, &n, &L) == 3) {
        clear();

        cin >> s;
        for (int i = 0; i < n; i++) {
            scanf("%d", &C[i]);
            cin >> t[i];
            maxl = max(maxl, (int)t[i].length());
        }

        solve_low_l();
    }
}
