#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>

using namespace std;
	
const int MAX = 3 * 1e5 + 13, INF = 1e9;

int m, n, L;

struct shablon {
	int c;
	string w;
};

string s;

void in(shablon &a) {
	cin >> a.c >> a.w;
}

map<string, int> mp;

int dp[MAX];

int  main() {
	//freopen("tests.txt", "r", stdin);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);

	cin >> m >> n >> L;

	cin >> s;

	for (int i = 1; i <= n; i++) {
		shablon sh;
		in(sh);
		for (int j = 1; j <= sh.w.size(); j++) {
			mp[sh.w.substr(0, j)] = min(mp[sh.w.substr(0, j)], sh.c);
			mp[sh.w.substr(sh.w.size() - j, j)] = min(mp[sh.w.substr(sh.w.size() - j, j)], sh.c);
		}
	}

	fill(dp + 1, dp + m + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		if (dp[i] == INF) {
			continue;
		}
		for (auto it = mp.begin(); it != mp.end(); ++it) {
			string ss = it->first;
			int c = it->second;
			string ch = s.substr(i, ss.size());
			if (ss == ch) {
				dp[i + ss.size()] = min(dp[i + ss.size()], dp[i] + c);
			}
		}
	}

	if (dp[m] == INF) {
		cout << -1;
		return 0;
	}
	cout << dp[m];
	return 0;
}