#include <bits/stdc++.h>

using namespace std;

int n, m, L;
string s;
int c[300000];
int go[300000][2];
long long val[300000];
int nx = 1;
long long dp[300001];

void add(int v, string x, int i, int pos) {
    if (pos == x.size()) {
        val[v] = min(val[v], c[i]);
        return;
    }
    int ch = x[pos] - '0';
    if (go[v][ch] != -1) {
        add(go[v][ch], x, i, pos + 1);
    } else {
        go[v][ch] = nx;
        nx++;
        add(nx - 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 < 300000; i++) {
        go[i][0] = -1;
        go[i][1] = -1;
        val[i] = 1e18;
    }
    for (int i = 0; i < m; i++) {
        string t;
        cin >> c[i] >> t;
        for (int j = 0; j < t.size(); j++) {
            add(0, t, i, j);
        }
    }
    for (int i = 1; i <= n; i++) {
        dp[i] = 1e18;
    }
    for (int i = 0; i < n; i++) {
        int v = 0;
        if (dp[i] > 1e17) {
            continue;
        }
        for (int j = i + 1; j <= n; j++) {
            v = go[v][s[j - 1] - '0'];
            if (v == -1) {
                break;
            }
            dp[j] = min(dp[j], dp[i] + val[v]);
        }
    }
    if (dp[n] < 1e17) {
        cout << dp[n] << "\n";
    } else {
        cout << "-1\n";
    }
}
