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

using namespace std;

int m, n, L;
int c[50010], d[400000];
string s, a, ao, st, so;
int nom, h1, p1, dl, zt[600000];
vector < pair <int, int> > g[400000], g1[400000];
set < pair <int, int> > qw;

inline void bz() {
	s += "#";
	st = s + a;
	zt[0] = 0;
	int l, r, d;
	l = 0;
	r = 0;
	for (int i = 1; i < st.length(); i++) {
		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 (int i = s.length(); i < st.length(); i++) {
		if (zt[i] != 0) {
			g1[i - s.length()].push_back(make_pair(nom, zt[i]));
		}
	}
}

inline void bzo() {
	so += "#";
	st = so + ao;
	zt[0] = 0;
	int l, r, d;
	l = 0;
	r = 0;
	for (int i = 1; i < st.length(); i++) {
		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 (int i = so.length(); i < st.length(); i++) {
		if (zt[i] != 0) {
			g[st.length() - (i + zt[i])].push_back(make_pair(nom, 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 (int i = a.length() - 1; i >= 0; i--) {
		ao += a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> s;
		nom = i;
		so = "";
		for (int j = s.length() - 1; j >= 0; j--) {
			so += s[j];
		}
		bz();
		bzo();
	}
	for (int i = 0; i <= m; i++) {
		d[i] = -1;
	}
	d[0] = 0;
	for (int 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 (int j = 0; j < g[i].size(); j++) {
			if (d[i + g[i][j].second] == -1) {
				d[i + g[i][j].second] = d[i] + c[g[i][j].first];
			}
			else {
				d[i + g[i][j].second] = min(d[i + g[i][j].second], d[i] + c[g[i][j].first]);
			}
		}
		for (int j = 0; j < g1[i].size(); j++) {
			qw.insert(make_pair(d[i] + c[g1[i][j].first], i + g1[i][j].second));
		}
	}
	while (qw.size() != 0 && qw.begin()->second < m) {
		qw.erase(qw.begin());
	}
	if (qw.size() != 0) {
		if (d[m] == -1) {
			d[m] = qw.begin()->first;
		}
		else {
			d[m] = min(d[m], qw.begin()->first);
		}
	}
	cout << d[m];
	return 0;
}