#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

#define fst first
#define snd second
#define sz(v_) (int((v_).size()))

using namespace std;

const int maxn = 7e5;
int m, n, l;

string s;
pair<int, string> q[maxn];
long long d[maxn];

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> m >> n >> l;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        cin >> q[i].fst >> q[i].snd;
    }
    //sort(q, q+n);
    string tmp;
    for (int i = 1; i <= m; ++i) {
        d[i] = 1e18;
        for (int k = 0; k < n; ++k) {
            for (int w = 1; w <= min(sz(q[k].snd), i); ++w) {
                tmp = s.substr(i-w, w);
                if (tmp == q[k].snd.substr(0, w) || tmp == q[k].snd.substr(sz(q[k].snd)-w, w)) {
                    d[i] = min(d[i], d[i-w]+q[k].fst);
                }
            }
        }
    }
    cout << (d[m] == 1e18 ? -1 : d[m]) << '\n';
    return 0;
}
