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

using namespace std;

typedef long long ll;

const int MAXN = 1e4 + 1;
const int SIZE = 2;
const ll INF = 1e18;

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

struct Node {
    ll cost;
    bool t;
    Node *go[SIZE];
    Node(ll cost = 0, bool t = false): cost(cost), t(t) {
        for (int i = 0; i < SIZE; i++)
            go[i] = NULL;
    }
};

Node *root = new Node();

void add(string s, ll cost) {
    Node *x = root;
    for (int i = 0; i < int(s.length()); i++) {
        if (x->go[num(s[i])] == NULL)
            x->go[num(s[i])] = new Node(cost, false);
        x = x->go[num(s[i])];
        if (i == int(s.length()) - 1)
            x->t = true;
        x->cost = min(x->cost, cost);
    }
}

ll ans[MAXN];

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

    int n, m, L; cin >> m >> n >> L;

    string s; cin >> s;

    for (int i = 0; i < n; i++) {
        int cost; string str; cin >> cost >> str;
        string p = "";
        for (int j = 0; j < int(str.length()); j++) {
            p = p + str[j];
            add(p, cost);
        }
        p = "";
        for (int j = int(str.length()) - 1; j >= 0; j--) {
            p = str[j] + p;
            add(p, 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;
            if (x->t)
                ans[nxt] = min(ans[nxt], k + x->cost);
            nxt++;
        }
    }

    if (ans[m - 1] == INF)
        cout << -1 << endl;
    else
        cout << ans[m - 1] << endl;

    return 0;
}
