#include <bits/stdc++.h>

using namespace std;

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

void add(int v, int i, int pos) {
    if (pos == t[i].size()) {
        return;
    }
    int ch = t[i][pos] - '0';
    if (go[v][ch] != -1) {
        add(go[v][ch], i, pos + 1);
        val[go[v][ch]] = min(val[go[v][ch]], c[i]);
    } else {
        go[v][ch] = nx;
        val[nx] = c[i];
        nx++;
        add(nx - 1, 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;
    }
    for (int i = 0; i < m; i++) {
        cin >> c[i] >> t[i];
        add(0, i, 0);
        string r = t[i];
        for (int j = 0; j < t[i].size(); j++) {
            r[j] = t[i][t[i].size() - 1 - j];
        }
        t[i] = r;
        add(0, i, 0);
    }
    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";
        return 1;
    }
}
