#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <vector>

#define mp  make_pair

using namespace std;

typedef long long int   ll;
typedef long double     ld;
typedef pair<int, int>    ii;
typedef vector<int>       vi;
typedef vector<ii>        vii;

const int MAXN = 200000;
const int INF = 1000000010;
const ll MOD = 1000000007LL;
const ll P = 5;

ll pwr(ll n, ll k) {
	ll res = 1;

	while (k) {
		if (k & 1)
			res = (res * n) % MOD;
		k >>= 1;
		n = (n*n) % MOD;
	}

	return res;
}

int M, N, L;
char s[MAXN], t[MAXN];
ll hsh[MAXN];
ll p[MAXN], dp[MAXN];
ll ans[MAXN];

ll get_hsh(int l, int r) {
	ll res = hsh[r];
	if (l)
		res = (res + MOD - hsh[l - 1]) % MOD;
	res = (res * dp[l]) % MOD;
	return res;
}

map<pair<int, ll>, ll> dc;

int main() {
#ifdef FILE_IO
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
#endif // FILE_IO

	scanf("%d %d %d", &M, &N, &L);

	assert(M <= 50000 && L <= 50000);

	p[0] = 1, p[1] = P;
	dp[0] = 1, dp[1] = pwr(P, MOD - 2);

	for (int i = 2; i <= 100000; i++) {
		p[i] = (p[i - 1] * p[1]) % MOD;
		dp[i] = (dp[i - 1] * dp[1]) % MOD;
	}

	scanf("%s", s);

	for (int i = 0; i < M; i++) {
		hsh[i] = ((s[i] - '0' + 1) * p[i]) % MOD;
		if (i > 0)
			hsh[i] = (hsh[i] + hsh[i - 1]) % MOD;
	}

	int ci, li;
	ll dhsh;
	pair<int, ll> tmp;
	for (int i = 0; i < N; i++) {
		scanf("%d %s", &ci, t);
		li = strlen(t);

		dhsh = 0;
		for (int j = 0; j < min(M, li); j++) {
			dhsh = (dhsh + (t[j] - '0' + 1)*p[j]) % MOD;

			tmp = mp(j + 1, dhsh);

			if (!dc.count(tmp))
				dc[tmp] = INF;
			dc[tmp] = min(dc[tmp], (ll)ci);
		}

		dhsh = 0;
		for (int j = 0; j < min(M, li); j++) {
			dhsh = (dhsh * P + (t[li - j - 1] - '0' + 1)) % MOD;

			tmp = mp(j + 1, dhsh);

			if (!dc.count(tmp))
				dc[tmp] = INF;
			dc[tmp] = min(dc[tmp], (ll)ci);
		}
	}

	memset(ans, -1, sizeof(ans));
	for (int i = 0; i < M; i++) {
		dhsh = get_hsh(0, i);

		tmp = mp(i + 1, dhsh);

		if (dc.count(tmp))
			ans[i] = dc[tmp];

		for (int j = 1; j <= i; j++) {
			dhsh = get_hsh(j, i);

			tmp = mp(i - j + 1, dhsh);

			if (dc.count(tmp) && ans[j - 1] != -1) {

				if (ans[i] == -1)
					ans[i] = ans[j - 1] + dc[tmp];
				else
					ans[i] = min(ans[i], ans[j - 1] + dc[tmp]);
			}
		}
	}

	printf("%lld", ans[M - 1]);

	return 0;
}