#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int inf_cost = 1e9 + 5;
const int maxn = 3e5 + 5;
const int maxw = 55 * 1e6;

int m, n, L;
int go[maxw][2];
int lastv = 1;
int cost[maxw];
ll d[maxn];

void add(const string &s, int w) {
    int node = 1;
    for (int i = 0; i < s.size(); i++) {
        int c = s[i] - '0';
        if (!go[node][c]) {
            lastv++;
            go[node][c] = lastv;
            cost[lastv] = inf_cost;
        }
        node = go[node][c];
    }
    cost[node] = min(cost[node], w);
}

void get(const string &s, int p) {
    d[p] = INF;
    int node = 1;
    for (int i = p; i < m; i++) {
        int c = s[i] - '0';
        node = go[node][c];
        if (!node) break;
        if (cost[node] != inf_cost) d[p] = min(d[p], d[i + 1] + cost[node]);
    }
}


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);

    cin >> m >> n >> L;
    string str;
    cin >> str;
    for (int i = 0; i < n; i++) {
        int w; string t;
        cin >> w >> t;
        for (int j = 0; j < t.size(); j++) {
            add(t.substr(j, t.size() - j), w);
            add(t.substr(0, j + 1), w);
        }
    }

    for (int i = m - 1; i >= 0; i--) {
        get(str, i);
    }

    if (d[0] == INF) cout << -1 << '\n';
    else cout << d[0] << '\n';
}

