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

using namespace std;

long long m, n, L, dp[10000], l;
string s;
map <string, long long> mm;

int main() {
	//ifstream cin("in.txt");
	//ofstream cout("out.txt");
	ifstream cin("typing.in");
	ofstream cout("typing.out");
	ios_base::sync_with_stdio(false);
	cin >> m >> n >> L;
	cin >> s;
	s = '0' + s;
	for (int i = 1; i <= n; i++) {
		string st;
		long long c;
		cin >> c >> st;
		for (int r = 0; r < st.size(); r++) {
			string ss;
			ss.clear();
			for (int p = 0; p <= r; p++)
				ss += st[p];
			for (int p = 0; p < ss.size() / 2; p++)
				swap(ss[p], ss[ss.size() - 1 - p]);
			if (mm[ss] == 0)
				mm[ss] = c;
			else
				mm[ss] = min(mm[ss], c);
		}
		for (int r = 0; r < st.size(); r++) {
			string ss;
			ss.clear();
			for (int p = r; p < st.size(); p++)
				ss += st[p];
			for (int p = 0; p < ss.size() / 2; p++)
				swap(ss[p], ss[ss.size() - 1 - p]);
			if (mm[ss] == 0)
				mm[ss] = c;
			else
				mm[ss] = min(mm[ss], c);
		}
	}
	for (int i = 1; i < s.size(); i++) {
		string st;
		st.clear();
		dp[i] = 1e18;
		for (int j = i - 1; j >= 0; j--) {
			st += s[j + 1];
			if (mm[st] != 0)
				dp[i] = min(dp[i], dp[j] + mm[st]);
		}
	}
	if (dp[m] == 1e18)
		cout << -1;
	else
		cout << dp[m];
	return 0;
}