#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>

using namespace std;

map<char, int> mp;
string s;
string w[300500];
int c[300500];

string rev(string a){
    reverse(a.begin(), a.end());
    return a;
}

int mod = 1000000007;
long long pw = 29;
int p[10000];
int h[50050][1050];
int hh[10500];
long long dp[100000];
/*
int get_hash(int l, int r){
    if (l == 0)
        return hh[r];
    int res = (hh[r] - hh[l - 1] * (long long)p[r - l + 1]) % mod;
    res = (res + mod) % mod;
    return res;
}*/

int get_hash(int t, int l, int r){
    if (l == 0)
        return h[t][r];
    int res = (h[t][r] - h[t][l - 1] * (long long)p[r - l + 1]) % mod;
    res = (res + mod) % mod;
    return res;
}
/*
int get_hash2(int t, int l, int r){
    if (l == 0)
        return rh[t][r];
    int res = (rh[t][r] - rh[t][l - 1] * (long long)p[r - l + 1]) % mod;
    res = (res + mod) % mod;
    return res;
}*/


int main(){
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int n, m, l;
    p[0] = 1;
    for (int i = 1; i < 10000; i++)
        p[i] = (p[i - 1] * pw) % mod;
    cin >> m >> n >> l;
    cin >> s;
    hh[0] = s[0] - '0';
    for (int i = 1; i < s.size(); i++)
        hh[i] = (hh[i - 1] * pw + s[i] - '0') % mod;
    for (int i = 0; i < n; i++){
        cin >> c[i] >> w[i];
        h[i][0] = w[i][0] - '0';
        for (int j = 1; j < w[i].size(); j++)
            h[i][j] = (h[i][j - 1] * pw + w[i][j] - '0') % mod;
    }
    //cout << hh[2] << " " << h[0][2] << " " << get_hash(0, 0, 2) << endl;
    dp[0] = 0;
    for (int i = 1; i <= m; i++)
        dp[i] = 1e18;
    for (int i = 0; i <= m; i++){
        if (dp[i] < 1e18)
        for (int t = 0; t < n; t++){
            for (int j = 0; j < w[t].size(); j++)
                if (j + 1 + i <= m)
                    if (hh[j] == h[t][j])
                    //if (s.substr(i, j + 1) == w[t].substr(0, j + 1))
                        dp[i + j + 1] = min(dp[i + j + 1], dp[i] + c[t]);
            for (int j = 0; j < w[t].size(); j++)
                if (j + 1 + i <= m)
                    if (hh[j] == get_hash(t, w[t].size() - j - 1, w[t].size() - 1))
                    //if (s.substr(i, j + 1) == w[t].substr(w[t].size() - j - 1, j + 1))
                        dp[i + j + 1] = min(dp[i + j + 1], dp[i] + c[t]);
        }

    }
    if (dp[m] > 1e16)
        cout << -1;
    else
        cout << dp[m];
    return 0;
}
