#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;

const long long BASE = 2;
const long long MOD = 42424243;

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

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


void calcHash(int i) {
    int sz = words[i].second.size();
    wordHash[i] = vector<int>(sz + 1, 0);
    for (int j = 1; j <= sz; j++) {
        wordHash[i][j] = (wordHash[i][j - 1] * BASE + words[i].second[j - 1]) % MOD;
    }
}

void readData(ifstream &fin) {
    pows[0] = 1;
    for (int i = 1; i <= MAX_L; i++) pows[i] = (pows[i - 1] * 2) % MOD;

    fin >> m >> n >> L;
    string in;
    fin >> in;
    inpHashArr[0] = 0;
    for (int i = 0; i < m; i++) {
        inp[i] = (in[i] == '1');
        inpHashArr[i + 1] = (inpHashArr[i] * BASE + inp[i]) % MOD;
    }
    for (int i = 0; i < n; i++) {
        int price;
        fin >> price >> in;
        words[i] = make_pair(price, 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());
        maxC = max(maxC, price);
    }

    sort(words, words + n, &comp);
    for (int i = 0; i < n; i++) calcHash(i);
}


int getMinP(int left, int right) {
    int length = right - left;

    int inpHash = (inpHashArr[right] - inpHashArr[left] * pows[length] + 1000 * MOD) % MOD;

    for (int i = 0; i < n; i++) {
        int sz = words[i].second.size();
        if (sz < length) continue;
        bool bad = false;
        if (false and inpHash != (wordHash[i][sz] - wordHash[i][sz - length] * pows[length] + 1000 * MOD) % MOD) bad = true;
        //else if (true) bad = false;
        else {
            for (int offs = 0; offs < length; offs++) {
                if (inp[left + offs] != words[i].second[sz - length + offs]) {
                    bad = true;
                    break;
                }
            }
        }
        if (!bad) return words[i].first;
        bad = false;
        if (false and inpHash != wordHash[i][length]) bad = true;
        //else if (true) bad = false;
        else {
            for (int offs = 0; offs < length; offs++) {
                if (inp[left + offs] != words[i].second[offs]) {
                    bad = true;
                    break;
                }
            }
        }
        if (!bad) return words[i].first;
    }
    return -1;
}

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].second) {
            cout << x;
        }
        cout << endl;
        for (auto x: hashSuff[i]) {
            cout << x << " ";
        }
        cout << endl;
    }
    */




    ans[0] = 0;
    for (int length = 1; length <= m; length++) {
        ans[length] = 1e16;
        for (int prevL = length - 1; prevL >= 0 and length - prevL <= maxL; 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;
}
