#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

const int INF = 1e9 + 7;

void z_func(vector<int> &z, string s) {
	int l = 0, r = 0, j = 0;
	for (int i = 1; i < s.length(); i++) {
		j = i;
		if (j < r) {
			z[i] = min(r - i + 1, z[i - l]);
			j += z[i];
		}
		while ((j < s.length()) && (s[j] == s[j - i])) {
			j++;
			z[i]++;
		}
		if (j > r) {
			l = i;
			r = j;
		}
	}
}



int main() {
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	int m, n, l;
	cin >> m >> n >> l;
	string s;
	cin >> s;
	vector< vector< pair<int, int> > > way (m, vector<pair<int, int> > ()); // ход и цена
	for (int i = 0; i < n; i++) {
		string w;
		int a;
		cin >> a;
		cin >> w;
		int wl = w.length();
		string e = w + "#" + s;
		vector<int> z1(e.length(), 0), z2(e.length(), 0);
		z_func(z1, e);
		for (int j = wl + 1; j < e.length(); j++) {
			if (z1[j] > 0) {
				way[j - wl - 1].push_back({ z1[j], a });
			}
		}
	


		string sr = s;
		reverse(sr.begin(), sr.end());
		reverse(w.begin(), w.end());
		e = w + "#" + sr;
		z_func(z2, e);
		for (int j = wl + 1; j < e.length(); j++) {
			if (z2[j] > 0) {
				for (int k = 1; k <= z2[j]; k++) {
					way[m - (j - wl + k - 1)].push_back({ k, a });
				}
			}
		}
	} 
	vector<int> dp(m + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		if (dp[i] == INF) {
			continue;
		}
		for (int j = 0; j < (int)way[i].size(); j++) {
			pair<int, int> p = way[i][j];
			dp[i + p.first] = min(dp[i + p.first], dp[i] + p.second);
		}
	}
	if (dp[m] == INF) {
		cout << -1;
	} else {
		cout << dp[m];
	}
	return 0;
}