#include <bits/stdc++.h>

using namespace std;

int n, m, L;
string s;
long long c[300000];
int go1[3000000][2];
long long val1[3000000];
int go2[3000000][2];
long long val2[3000000];
int nx1 = 1;
int nx2 = 1;
long long dp[300001];

void add1(int v, string x, int i, int pos) {
    if (pos == x.size()) {
        return;
    }
    int ch = x[pos] - '0';
    if (go1[v][ch] != -1) {
        add1(go1[v][ch], x, i, pos + 1);
        val1[go1[v][ch]] = min(c[i], val1[go1[v][ch]]);
    } else {
        go1[v][ch] = nx1;
        val1[nx1] = c[i];
        nx1++;
        add1(nx1 - 1, x, i, pos + 1);
    }
}

void add2(int v, string x, int i, int pos) {
    if (pos == -1) {
        return;
    }
    int ch = x[pos] - '0';
    if (go2[v][ch] != -1) {
        add2(go2[v][ch], x, i, pos - 1);
        val2[go2[v][ch]] = min(c[i], val2[go2[v][ch]]);
    } else {
        go2[v][ch] = nx2;
        val2[nx2] = c[i];
        nx2++;
        add2(nx2 - 1, x, i, pos - 1);
    }
}

int main() {
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> L >> s;
    for (int i = 0; i < 3000000; i++) {
        go1[i][0] = -1;
        go1[i][1] = -1;
        val1[i] = 1e18;
        go2[i][0] = -1;
        go2[i][1] = -1;
        val2[i] = 1e18;
    }
    for (int i = 0; i < m; i++) {
        string t;
        cin >> c[i] >> t;
        add1(0, t, i, 0);
        add2(0, t, i, t.size() - 1);
    }
    for (int i = 1; i <= n; i++) {
        dp[i] = 1e18;
    }
    for (int i = 0; i <= n; i++) {
        int v = 0;
        for (int j = i - 1; j >= 0; j--) {
            v = go2[v][s[j] - '0'];
            if (v == -1) {
                break;
            }
            dp[i] = min(dp[i], dp[j] + val2[v]);
        }
        v = 0;
        for (int j = i + 1; j <= n; j++) {
            v = go1[v][s[j - 1] - '0'];
            if (v == -1) {
                break;
            }
            dp[j] = min(dp[j], dp[i] + val1[v]);
        }
    }
    if (dp[n] < 1e17) {
        cout << dp[n] << "\n";
    } else {
        cout << "-1\n";
    }
}
