#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstdlib>

#define ll long long
#define ld long double
#define mp make_pair
#define sz(x) (int) x.size()

using namespace std;

#define TASKNAME "typing"

const int N = 3e5;
const ll LINF = 1e18;

int m, n, L;
int a[N];
string words[N];
vector<int> sh;
vector<int> h[N];
ll dp[N];
ll cost[N];
int pw[N];

const int P = 179;
const int MOD = 1e9 + 7;

vector<int> calc(string &s) {
	vector<int> ans(sz(s));
	ans[0] = s[0];
	for (int i = 1; i < sz(s); i++) {
		ans[i] = (ans[i - 1] * 1LL * P + s[i]) % MOD;
	}
	return ans;
}

int substr(vector<int> &q, int l, int r) {
	int res = q[r];
	if (l > 0) {
		res -= q[l - 1] * pw[r - l + 1];
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#else
	if (TASKNAME != "") {
		freopen(TASKNAME ".in", "r", stdin);
		freopen(TASKNAME ".out", "w", stdout);
	}
#endif

	pw[0] = 1;
	for (int i = 1; i < N; i++) {
		pw[i] = (pw[i - 1] * P) % MOD;
	}

	cin >> m >> n >> L;

	string s;
	cin >> s;
	sh = calc(s);

	for (int i = 0; i < n; i++) {
		cin >> cost[i];
		cin >> words[i];
		h[i] = calc(words[i]);
	}

	fill(dp, dp + N, LINF);
	dp[0] = 0;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < sz(words[j]) && i + k < m; k++) {
				if (s[i + k] != words[j][k]) {
					break;
				}

				dp[i + k + 1] = min(dp[i + k + 1], dp[i] + cost[j]);
			}

			for (int k = 0; k < sz(words[j]); k++) {
				int len = sz(words[j]) - k;
				if (i + len - 1 >= m) continue;
				if (substr(sh, i, i + len - 1) == substr(h[j], k, k + len - 1)) {
					dp[i + len] = min(dp[i + len], dp[i] + cost[j]);
				}
			}
		}
	}

	cout << (dp[m] == LINF ? -1 : dp[m]) << endl;

#ifdef _DEBUG
	while (1);
#endif

	return 0;
}