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

using namespace std;

int main(){
    const long long INF = 1000000000000000;
    ifstream fin("typing.in");
    ofstream fout("typing.out");

    int m, n, L;

    fin >> m >> n >> L;

    string text;

    fin >> text;

    vector< pair<long long, string> > mas(n);
    for(int i = 0; i < n; ++i){
        fin >> mas[i].first >> mas[i].second;
    }


    vector<long long> dp(m + 1, INF);
    dp[0] = 0;

    int uk1, uk2;
    for(int i = 1; i < m + 1; ++i){
        for(int j = 0; j < n; ++j){
            uk1 = i - 1;
            uk2 = mas[j].second.size() - 1;

            while (uk1 >= 0 && uk2 >= 0 && text[uk1] == (mas[j].second)[uk2]){
                dp[i] = min(dp[uk1] + mas[j].first, dp[i]);
                uk1--;
                uk2--;
            }

            uk1 = i - 1;
            uk2 = 0;

            while (uk1 < m && uk2 < mas[j].second.size() && text[uk1] == (mas[j].second)[uk2]){
                dp[uk1 + 1] = min(dp[uk1 + 1], dp[i - 1] + mas[j].first);
                uk1++;
                uk2++;
            }
        }
    }

    if (dp[m] >= INF){
        fout << -1 << endl;
    }
    else{
        fout << dp[m] << endl;
    }

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