#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 3e5;
const int MAX_M = 3e5;
const int MAX_L = 3e5;

int m, n, L, maxL = 0;
bool inp[MAX_M];
pair<int, vector<bool>> words[MAX_N];
int price[MAX_N];
long long ans[MAX_M + 1];

bool comp(const pair<int, vector<bool>> &w1, const pair<int, vector<bool>> &w2) {
    return w1.first < w2.first;
}

void readData(ifstream &fin) {
    fin >> m >> n >> L;
    string in;
    fin >> in;
    for (int i = 0; i < m; i++) {
        inp[i] = (in[i] == '1');
    }
    for (int i = 0; i < n; i++) {
        fin >> price[i] >> in;
        words[i] = make_pair(price[i], vector<bool>(in.size()));
        for (int j = 0; j < in.size(); j++) {
            words[i].second[j] = (in[j] == '1');
        }
        maxL = max(maxL, (int)in.size());
    }

    //sort(words, words + n, &comp);
}

int getMinP(int left, int right) {
    int length = right - left;
    int ans = 2e9;
    for (int i = 0; i < n; i++) {
        int sz = words[i].second.size();
        //cout << i << ": " << sz << endl;
        if (sz < length) continue;
        bool bad = false;
        for (int offs = 0; offs < length; offs++) {
            if (inp[left + offs] != words[i].second[offs]) {
                bad = true;
                break;
            }
        }
        if (!bad) {
            ans = min(ans, words[i].first);
            continue;
        }
        bad = false;
        //cout << "badPref" << endl;
        for (int offs = 0; offs < length; offs++) {
            if (inp[left + offs] != words[i].second[sz - length + offs]) {
                bad = true;
                break;
            }
        }
        if (!bad) ans = min(ans, words[i].first);
        //else cout << "badSuff" << endl;
    }
    return (ans == 2e9) ? -1 : ans;
}

int main() {
    ifstream fin("typing.in");
    ofstream fout("typing.out");

    readData(fin);
    /*
    cout << m << " " << n << " " << L << endl;
    for (int i = 0; i < m; i++) {
        cout << inp[i];
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
        for (auto x: words[i]) {
            cout << x;
        }
        cout << endl;
    }
    */

    ans[0] = 0;
    for (int length = 1; length <= m; length++) {
        ans[length] = 1e16;
        for (int prevL = 0; prevL < length; prevL++) {
            int p = getMinP(prevL, length);
            if (p != -1) ans[length] = min(ans[length], ans[prevL] + p);
        }
        //cout << ans[length] << endl;
    }

    fout << ((ans[m] < 1e15) ? ans[m] : -1);

    fin.close();
    fout.close();
    return 0;
}
