#include <fstream>

using namespace std;

int main() {
    ifstream cin("typing.in");
    ofstream cout("typing.out");
    int m, n, l;
    cin >> m >> n >> l;
    string s, pats[n];
    int cost[n];
    cin >> s;
    for (int i = 0; i < n; i++)
        cin >> cost[i] >> pats[i];
    int d[m + 1];
    d[0] = 0;
    for (int i = 1; i <= m; i++) {
        d[i] = 1e9;
        for (int j = 0; j < n; j++) {
            for (int k = 1; k <= pats[j].size() && i - k >= 0; k++) {
                if (d[i - k] >= 1e9)
                    continue;
                if(s.substr(i - k, k) == pats[j].substr(0, k) || s.substr(i - k, k) == pats[j].substr(pats[j].size() - k, k))
                    d[i] = d[i - k] + cost[j];
            }
        }
    }
    if (d[m] >= 1e9)
        cout << -1;
        else
    cout << d[m];
    return 0;
}
