#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
const long long r = 1000000000000000;
long long n, m, l, i, j, p[201], d[201], x=0, k;
string s[201], s1;
int main() {
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	cin >> n >> m >> l;
	cin >> s1;
	m *= 2;
	d[0] = 0;
	for (i = 0; i < m; i+=2) {
		cin >> p[i]>>s[i];
		x = s[i].length();
		for (j = 0; j < x; j++) {
			s[i + 1]+= s[i][x - j - 1];
		}
		p[i + 1] = p[i];
	}
	for (i = 0; i < n; i++) {
		d[i] = r;
		for (j = 0; j < m; j++) {
			x = s[j].length()-1;
			k = i;
			while (k>=0&&x>=0&&s[j][x]==s1[k]) {
				x--;
				k--;
			}
			if (d[i-s[j].length()+1+x]+p[j]<d[i]) {
				d[i] = d[i - s[j].length() + 1 + x] + p[j];
			}
		}
	}
	if (d[n-1]==r) {
		cout << "-1";
		return 0;
	}
	cout << d[n - 1];
}