#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll lot = 1e+18;
const ll inf = 1e+9 + 7;
const ll prime = 3;
const int limm = 50001;
const int liml = 50001;
const int limn = liml;

ll max(ll a, ll b) {
	return (a > b ? a : b);
}

ll min(ll a, ll b) {
	return (a < b ? a : b);
}

int slen, n;
char s[limm];
ll hashs[limm];
ll pows[limm];

ll subhash(int l, int r) {
	if (!l)
		return hashs[r];
	return ((hashs[r] - hashs[l - 1] * pows[r - l + 1]) % inf + inf) % inf;
}

ll dp[limm];
char sam[liml * 2];
int start[limn];
int len[limn];
int cost[limn];

unordered_map<ll, int> hashes;

int main() {
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	int i, j, pingas, next = 0;
	int maxl = 0;
	scanf("%d %d %d", &slen, &n, &pingas);
	scanf("%s", &s);
	for (i = 0; i < slen; ++i) {
		hashs[i] = ((i ? hashs[i - 1] : 0) * prime + s[i] - '0' + 1) % inf;
		pows[i] = (i ? (pows[i - 1] * prime) % inf : 1);
	}

	for (i = 0; i < n; ++i) {
		scanf("%d %s", &cost[i], (sam + next));
		start[i] = next;
		next += strlen(sam + next) + 1;
		len[i] = next - start[i] - 1;
		maxl = max(maxl, len[i]);
	}
	for (i = 0; i < n; ++i) {
		ll curhash = 0;
		for (j = 0; j < len[i]; ++j) {
			curhash = (curhash * prime + sam[j + start[i]] - '0' + 1) % inf;
			if (hashes.find(curhash) == hashes.end() || hashes[curhash] > cost[i])
				hashes[curhash] = cost[i];
		}
	}
	for (i = 0; i < n; ++i) {
		ll curhash = 0;
		for (j = len[i] - 1; j >= 0; --j) {
			curhash = (curhash + (sam[j + start[i]] - '0' + 1) * pows[len[i] - 1 - j]) % inf;
			if (hashes.find(curhash) == hashes.end() || hashes[curhash] > cost[i])
				hashes[curhash] = cost[i];
		}
	}

	for (i = 0; i < slen; ++i)
		dp[i] = lot;
	for (i = 0; i < slen; ++i)
		for (j = max(0, i - maxl); j <= i; ++j) {
			int sh = subhash(j, i);
			if (hashes.find(sh) != hashes.end())
				dp[i] = min(dp[i], (j ? dp[j - 1] : 0) + hashes[sh]);
		}
	printf("%d", (dp[slen - 1] == lot ? -1 : dp[slen - 1]));
	return 0;
}