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

using namespace std;

typedef long long ll;

ll m, n, L, c[600000], d[300000];

string s, a[600000];

const int inf = 1000000000;

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