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

using namespace std;

const long long MAX = 3 * 1e5 + 13, INF = 1e16, p = 31;

long long m, n, L;

struct shablon {
	long long c;
	string w;
};

string s;

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

map<string, long long> mp;

map<pair<long long, long long>, long long> mpp;

long long dp[MAX];

long long hsh[MAX], step[MAX];

long long max(long long a, long long b) {
	if (a > b) {
		return a;
	}
	return b;
}

long long min(long long a, long long b) {
	if (a < b) {
		return a;
	}
	return b;
}
int main() {
	//freopen("tests.txt", "r", stdin);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);

	cin >> m >> n >> L;

	cin >> s;
	
	step[0] = 1;
	for (long long i = 1; i <= m + 13; i++) {
		step[i] = step[i - 1] * p;
	}

	for (long long i = 0; i < s.size(); i++) {
		hsh[i] = hsh[i - 1] + s[i] * step[i];
	}

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

	for (auto it = mp.begin(); it != mp.end(); ++it) {
		long long c = it->second;
		string ss = it->first;
		long long sum = 0;
		for (long long i = 0; i < ss.size(); i++) {
			sum += step[i] * ss[i];
		}
		mpp[ make_pair(sum, (long long)ss.size ())] = c;
	}

	fill(dp + 1, dp + m + 1, INF);
	dp[0] = 0;
	for (long long i = 0; i < m; i++) {
		if (dp[i] == INF) {
			continue;
		}
		for (auto it = mpp.begin(); it != mpp.end(); ++it) {
			long long s = it->first.first, dl = it->first.second;
			long long c = it->second;
			long long l = s * step[i], r = hsh[i + dl - 1] - hsh[i - 1];
			if (l == r) {
				dp[i + dl] = min(dp[i + dl], dp[i] + c);
			}
		}
	}

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