#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cassert>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 1e5;
const int SIZE = 2;
const ll INF = 1e14;

int num(const char &r) { return r - '0'; }

struct Node {
    ll cost[2];
    Node *go[SIZE];
    Node() {
        cost[0] = cost[1] = INF;
        for (int i = 0; i < SIZE; i++)
            go[i] = NULL;
    }
};

Node *root = new Node();

char str[MAXN];

void add(const int &l, const int &r, const ll &cost) {
    Node *x = root;
    for (int i = l; i <= r; i++) {
        if (x->go[num(str[i])] == NULL)
            x->go[num(str[i])] = new Node();
        x = x->go[num(str[i])];
        if (i == r)
            x->cost[1] = min(x->cost[1], cost);
        else
            x->cost[0] = min(x->cost[0], cost);
    }
}

ll ans[MAXN];
char s[MAXN];

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

    int n, m, L; scanf("%d%d%d", &m, &n, &L);

    scanf("%s", s);

    for (int i = 0; i < n; i++) {
        int cost; scanf("%d", &cost);
        scanf("%s", str);
        int k = strlen(str);
        for (int j = 0; j < k; j++) {
            add(0, j, cost);
            add(j, k - 1, cost);
        }
    }

    for (int i = 0; i < m; i++)
        ans[i] = INF;
    for (int i = -1; i < m; i++) {
        ll k = 0;
        if (i >= 0)
            k = ans[i];
        Node *x = root;
        int nxt = i + 1;
        while (nxt < m) {
            x = x->go[num(s[nxt])];
            if (x == NULL)
                break;
            ans[nxt] = min(ans[nxt], k + x->cost[1]);
            nxt++;
        }
    }

    if (ans[m - 1] == INF)
        printf("-1\n");
    else
        printf("%d\n", ans[m - 1]);

    return 0;
}
