#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define point pair <int, int>
#define For(i, a, b) for(int i = a; i < b; ++i)
#define Out(i, a, b) for(int i = a - 1; i >= b; --i)
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)

using namespace std;

string FileName = "typing";

typedef long long base;

int n, k, L;
string s;
unordered_map <int, set <int>> cost[2001];

const int p1 = 1e9 + 7, p2 = 1e9 + 9;
base Pow[300001][2];
pair <base, base> Hash[2001];
base dp[300001];
int main() {
    ios::sync_with_stdio(false);
    files(FileName);
    cin >> n >> k >> L;
    cin >> s;
    Pow[0][0] = Pow[0][1] = 1;
    For(i, 1, 3e5 + 1) {
        Pow[i][0] = Pow[i-1][0]*2; if (Pow[i][0] >= p1) Pow[i][0] -= p1;
        Pow[i][1] = Pow[i-1][1]*2; if (Pow[i][1] >= p2) Pow[i][1] -= p2;
    }
    For(q, 0, k) {
        int c; string s;
        cin >> c >> s;
        Hash[0] = {0, 0};
        For(i, 0, s.size()) {
            s[i] -= '0';
            Hash[i + 1].x = Hash[i].x * 2 + s[i]; Hash[i + 1].x %= p1;
            Hash[i + 1].y = Hash[i].y * 2 + s[i]; Hash[i + 1].y %= p2;
            auto N = make_pair(Hash[i + 1], i + 1);
            if (cost.count(N)) {
                cost[N] = min(cost[N], c);
            } else {
                cost[N] = c;
            }
        }
        Hash[s.size()] = {0, 0};
        Out(i, s.size(), 0) {
            Hash[i].x = Hash[i + 1].x + Pow[s.size() - i - 1][0] * s[i]; Hash[i].x %= p1;
            Hash[i].y = Hash[i + 1].y + Pow[s.size() - i - 1][1] * s[i]; Hash[i].y %= p2;
            auto N = make_pair(Hash[i], s.size() - i);
            if (cost.count(N)) {
                cost[N] = min(cost[N], c);
            } else {
                cost[N] = c;
            }
        }
    }
    For(i, 0, n) s[i] -= '0';
    For(i, 1, n + 1) dp[i] = -1;
    For(i, 0, n) {
        if (dp[i] == -1) continue;
        pair <base, base> H = {0, 0};
        For(j, 0, min(2001, n - i)) {
            H.x = (H.x<<1) + s[i + j]; while (H.x >= p1) H.x -= p1;
            H.y = (H.y<<1) + s[i + j]; while (H.y >= p2) H.y -= p2;
            auto N = make_pair(H, j + 1);
            if (cost.count(N)) {
                base c = cost[N];
                if (dp[i + j + 1] == -1 || dp[i + j + 1] > dp[i] + c) {
                    dp[i + j + 1] = dp[i] + c;
                }
            }
        }
    }
    cout << dp[n] << endl;
}
