#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

map <string, long long> q;

int main() {
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	vector <long long> dp;
	vector <string> voc;
	vector < long long > prc;
	string s;
	long long n, m, l;
	cin >> m >> n >> l;
	voc.resize(n);
	prc.resize(n);
	cin >> s;
	for (int i = 0; i < n; i++) {
		cin >> prc[i] >> voc[i];
		for (int j = 1; j <= voc[i].length(); j++) {
			string c1, c2;
			c1 = voc[i].substr(0, j);
			c2 = voc[i].substr(voc[i].length() - j, j);
			if (q[c1] == 0 || q[c1] > prc[i])
				q[c1] = prc[i];
			if (q[c2] == 0 || q[c2] > prc[i])
				q[c2] = prc[i];
		}
	}
	dp.resize(m + 1, 1e18);
	dp[m] = 0;
	for (int i = m - 1; i >= 0; i--) {
		for (int j = 1; j <= m - i; j++) {
			long long x = 1e18;
			if (q[s.substr(i, j)] != 0)
				x = q[s.substr(i, j)];
			dp[i] = min(dp[i], dp[i + j] + x);
		}
	}
	if (dp[0] == 1e18)
		cout << -1;
	else
		cout << dp[0];
	return 0;
}