#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <set>
#include <vector>

using namespace std;

long long m, n, L;
long long c, d[400000];
string s, a, ao, st, so;
long long nom, h1, p1, dl, zt[600000], da, ds, dst, dao, dso;
vector < pair <long long, long long> > g[400000], g1[400000];
set < pair <long long, long long> > qw;

inline void bz() {
	s += "#";
	st = s + a;
	zt[0] = 0;
	long long l, r, d;
	l = 0;
	r = 0;
	for (long long i = 1; i < st.length(); i++) {
		zt[i] = 0;
		d = 0;
		if (i <= r) {
			d = zt[i - l];
		}
		while (d + i < st.length() && st[d + i] == st[d]) {
			d++;
		}
		if (i + d - 1 > r) {
			r = i + d - 1;
			l = i;
		}
		zt[i] = d;
	}
	for (long long i = s.length(); i < st.length(); i++) {
		if (zt[i] != 0) {
			g1[i - s.length()].push_back(make_pair(c, zt[i]));
		}
	}
}

inline void bzo() {
	so += "#";
	st = so + ao;
	zt[0] = 0;
	long long l, r, d;
	l = 0;
	r = 0;
	for (long long i = 1; i < st.length(); i++) {
		zt[i] = 0;
		d = 0;
		if (i <= r) {
			d = zt[i - l];
		}
		while (d + i < st.length() && st[d + i] == st[d]) {
			d++;
		}
		if (i + d - 1 > r) {
			r = i + d - 1;
			l = i;
		}
		zt[i] = d;
	}
	for (long long i = so.length(); i < st.length(); i++) {
		if (zt[i] != 0) {
			g[st.length() - (i + zt[i])].push_back(make_pair(c, zt[i]));
		}
	}
}

int main() {
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//cout.tie(0);
	cin >> m >> n >> L;
	cin >> a;
	for (long long i = a.length() - 1; i >= 0; i--) {
		ao += a[i];
	}
	for (long long i = 0; i < n; i++) {
		cin >> c >> s;
		so = "";
		for (long long j = s.length() - 1; j >= 0; j--) {
			so += s[j];
		}
		bz();
		bzo();
	}
	for (long long i = 0; i <= m; i++) {
		d[i] = -1;
	}
	d[0] = 0;
	for (long long i = 0; i <= m; i++) {
		while (qw.size() != 0 && qw.begin()->second < i) {
			qw.erase(qw.begin());
		}
		if (qw.size() != 0) {
			if (d[i] == -1) {
				d[i] = qw.begin()->first;
			}
			else {
				d[i] = min(d[i], qw.begin()->first);
			}
		}
		if (d[i] == -1) {
			continue;
		}
		for (long long j = 0; j < g[i].size(); j++) {
			if (d[i + g[i][j].second] == -1) {
				d[i + g[i][j].second] = d[i] + g[i][j].first;
			}
			else {
				d[i + g[i][j].second] = min(d[i + g[i][j].second], d[i] + g[i][j].first);
			}
		}
		for (long long j = 0; j < g1[i].size(); j++) {
			qw.insert(make_pair(d[i] + g1[i][j].first, i + g1[i][j].second));
		}
	}
	cout << d[m];
	return 0;
}