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

using namespace std;

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];
	}
	dp.resize(m + 1, 1e18);
	dp[m] = 0;
	for (int i = m - 1; i >= 0; i--) {
		for (int j = 0; j < n; j++) {
			int x = 1;
			while (x <= voc[j].length() && i + x - 1 < m && s.substr(i, x) == voc[j].substr(0, x)) {
				dp[i] = min(dp[i], dp[i + x] + prc[j]);
				x++;
			}
			for (int x = 0; x < voc[j].length(); x++) {
				if (i + x - 1 < m && s.substr(i, x) == voc[j].substr(voc[j].length() - x, x)) {
					dp[i] = min(dp[i], dp[i + x] + prc[j]);
				}
			}
		}
	}
	if (dp[0] == 1e18)
		cout << -1;
	else
		cout << dp[0];
	return 0;
}