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

using namespace std;

int m, n, L;
int c, d[300500];
string s, a, ao, st, so;
int nom, h1, p1, dl, zt[400000], da, ds, dst, dao, dso;
map <int, int> g[300500], g1[300500];
map <int, int>::iterator it;
set < pair <int, int> > qw;
int tree[605000];
int md;

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++) {
		zt[i] = 0;
		d = 0;
		if (i <= r) {
			d = min(zt[i - l], r - i + 1);
		}
		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) {
			if (g1[i - int(s.length())][zt[i]] == 0) {
				g1[i - int(s.length())][zt[i]] = c;
			}
			else {
				g1[i - int(s.length())][zt[i]] = min(g1[i - int(s.length())][zt[i]], c);
			}
		}
	}
}

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++) {
		zt[i] = 0;
		d = 0;
		if (i <= r) {
			d = min(zt[i - l], r - i + 1);
		}
		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) {
			if (g[int(st.length()) - i][zt[i]] == 0) {
				g[int(st.length()) - i][zt[i]] = c;
			}
			else {
				g[int(st.length()) - i][zt[i]] = min(g[int(st.length()) - i][zt[i]], c);
			}
		}
	}
}

inline void update() {
	tree[md + nom] = d[nom];
	nom = md + nom;
	nom = nom / 2;
	while (nom != 0) {
		tree[nom] = min(tree[2 * nom], tree[2 * nom + 1]);
		if (tree[2 * nom] == -1) {
			tree[nom] = tree[2 * nom + 1];
		}
		if (tree[2 * nom + 1] == -1) {
			tree[nom] = tree[2 * nom];
		}
		nom = nom / 2;
	}
	return;
}

int getm(int v, int l, int r, int tl, int tr) {
	if (tl >= l && tr <= r) {
		return tree[v];
	}
	if (tl > r || tr < l) {
		return -1;
	}
	int tm = (tr + tl) / 2;
	int ans1, ans2;
	ans1 = getm(v * 2, l, r, tl, tm);
	ans2 = getm(v * 2 + 1, l, r, tm + 1, tr);
	if (ans1 == -1) {
		return ans2;
	}
	if (ans2 == -1) {
		return ans1;
	}
	return min(ans2, ans1);
}

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 >> s;
		so = "";
		for (int j = s.length() - 1; j >= 0; j--) {
			so += s[j];
		}
		bz();
		bzo();
	}
	for (md = 1; md < m + 10; md = md * 2) {}
	for (int i = 0; i <= 2 * md; i++) {
		tree[i] = -1;
	}
	for (int i = 0; i <= m; i++) {
		d[i] = -1;
	}
	d[0] = 0;
	int as;
	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);
			}
		}
		for (it = g[i].begin(); it != g[i].end(); it++) {
			as = getm(1, i - it->first, i - 1, 0, md - 1);
			if (as == -1) {
				continue;
			}
			if (d[i] == -1) {
				d[i] = as + it->second;
			}
			else {
				d[i] = min(d[i], as + it->second);
			}
		}
		if (d[i] == -1) {
			continue;
		}
		nom = i;
		update();
		for (it = g1[i].begin(); it != g1[i].end(); it++) {
			qw.insert(make_pair(d[i] + it->second, i + it->first));
		}
	}
	cout << d[m];
	return 0;
}