#include <iostream>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <set>
#include <algorithm>
#include <string>
#include <map>
//#include <unordered_map>

using namespace std;

const long long INF = 1e18;

const int maxN = 50005;

pair<long long, string> dict[maxN];

long long h_t[maxN];

map<long long, long long> hash_dict;

//long long mod;

long long h_str[maxN];
long long p_st[maxN];

void build_step(long long n, long long p)
{
    p_st[0] = 1;
    for(long long i = 1; i <= n; i++) p_st[i] = p_st[i-1]*p;
}

void build_hash(string &str, long long* h, long long p)
{
    h[0] = str[0];
    for(long long i = 1; i < str.size(); i++) h[i] = h[i-1]*p + str[i];
}

long long get_hash(long long* h, long long l, long long r)
{
    if(l == 0) return h[r];
    return h[r] - h[l-1]*p_st[r-l+1];
}

void build_hash_dict(long long n, long long p)
{
    build_step(maxN, p);

    for(long long i = 0; i < n; i++)
    {
        build_hash(dict[i].second, h_t, p);
        for(long long r = 0; r < dict[i].second.size(); r++)
        {
            long long h = get_hash(h_t, 0, r);
            if(hash_dict.count(h)) hash_dict[h] = min(hash_dict[h], dict[i].first);
            else hash_dict[h] = dict[i].first;
        }
        for(long long l = 0; l < dict[i].second.size(); l++)
        {
            long long h = get_hash(h_t, l, dict[i].second.size()-1);
            if(hash_dict.count(h)) hash_dict[h] = min(hash_dict[h], dict[i].first);
            else hash_dict[h] = dict[i].first;
        }
    }
}

long long dp[maxN];

string str;
long long m, n, L;

long long get_min(long long l, long long r)
{
    long long h = get_hash(h_str, l, r);
    if(hash_dict.count(h)) return hash_dict[h];
    return INF;
}

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

    //hash_dict.rehash(20*maxN);

    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> m >> n >> L;

    cin >> str;

    for(long long i = 0; i < n; i++)
    {
        cin >> dict[i].first >> dict[i].second;
    }

    build_hash_dict(n, 239);
    build_hash(str, h_str, 239);

    dp[0] = 0;

    if(n > 200)
    {
        for(int i = 1; i <= m; i++)
        {
            dp[i] = INF;
            for(int k = 0; k < i; k++)
            {
                dp[i] = min(dp[i], dp[k] + get_min(k, i-1));
            }
        }
    }
    else
    {
        for(int i = 1; i <= m; i++)
        {
            dp[i] = INF;

            for(int k = 0; k < n; k++)
            {
                if(get_min(i-1, i-1) == INF) continue;

                int l = i - dict[k].second.size() - 1, r = i-1;

                while(r - l > 1)
                {
                    int m = (r+l)/2;
                    if(get_min(m, i-1) != INF) r = m;
                    else l = m;
                }

                dp[i] = min(dp[i], dp[r] + get_min(r, i-1));
            }
        }
    }

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




    return 0;
}

