#include <iostream>
#include <fstream>
#include <set>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <vector>

using namespace std;
int n, m, L, d[300001], c[300000];
string s, a[600000];
const int inf = 1000000000;

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    cin >> n >> m >> L;
    cin >> s;
    for (int i = 0; i < m; i++){
        string s1;
        cin >> c[i] >> s1;
        a[i] = s1;
        reverse(s1.begin(), s1.end());
        a[i + m] = s1;
        c[i + m] = c[i];
    }
    d[0] = 0;
    for (int i = 1; i <= n; i++){
        d[i] = inf;
        for (int j = 0; j < m * 2; j++){
            int i1 = i - 1, i2 = (int)a[j].size() - 1;
            while (i1 >= 0 && i2 >= 0 && a[j][i2] == s[i1]){
                i1--;
                i2--;
            }
            for (int k = i1 + 1; k < i; k++)
                d[i] = min(d[i], d[k] + c[j]);
        }
    }
    //for (int i = 0; i <= n; i++)
    //    cout << d[i] << ' ';
    cout << d[n] << endl;
    return 0;
}
