#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <string>

using namespace std;

const int sz = 1e2;
const int inf = 1e9;

struct str {
	int c;
	string s;
};

string need;
str ar[sz];
int n, m, l;
int brevno[sz];

int rec(int pos) {
	if (pos == m) {
		return 0;
	}
	if (brevno[pos] != 0) {
		return brevno[pos];
	}
	int res = inf;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < ar[i].s.size() && pos + j < m; j++) {
			if (need[pos + j] == ar[i].s[j]) {
				res = min(res, rec(pos + j + 1) + ar[i].c);
			}
			else {
				break;
			}
		}
		for (int j = 0; j < ar[i].s.size() && pos + j < m; j++) {
			if (need[pos + j] == ar[i].s[ar[i].s.size() - j - 1]) {
				res = min(res, rec(pos + j + 1) + ar[i].c);
			}
			else {
				break;
			}
		}
	}
	brevno[pos] = res;
	return res;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	scanf("%d%d%d", &m, &n, &l);
	cin >> need;
	for (int i = 0; i < n; i++) {
		cin >> ar[i].c >> ar[i].s;
	}
	int res = rec(0);
	if (res == inf) {
		printf("-1");
	}
	else {
		printf("%d", res);
	}
	return 0;
}