#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <ctime>
#include <set>
#include <unordered_set>
#include <unordered_map>
#pragma comment(linker, "/stack:100000000")
#define ll long long
#define ld long double
#define cs(x) (int)x.size()
#define mp make_pair

using namespace std;

const int MAXN = 100000;

ll tohash(pair<ll, ll> a) {
	return (a.first << 32) | (a.second);
}

pair<ll, ll> p = mp(307, 37);
ll mod = 1e9 + 7;

ll sum(ll a, ll b) {
	a += b;
	if (a >= mod)
		a -= mod;
	return a;
}

void add(ll & a, ll b) {
	a += b;
	if (a >= mod)
		a -= mod;
}

ll mult(ll a, ll b) {
	return a * b % mod;
}

vector<pair<ll, ll> > pstep;

void precalc() {
	pstep.resize(300001);
	pstep[0] = mp(1, 1);
	for (int i = 1; i < cs(pstep); i++) {
		pstep[i].first = mult(pstep[i - 1].first, p.first);
		pstep[i].second = mult(pstep[i - 1].second, p.second);
	}
}

const ll INF = 1e18;

int main() {
	precalc();
	iostream::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	int n, m, l;
	cin >> n >> m >> l;
	string s;
	cin >> s;
	unordered_map<ll, int> cost;
	for (int i = 0; i < m; i++) {
		int c;
		string s1;
		cin >> c >> s1;
		pair<ll, ll> curhash = mp(0, 0);
		for (int i = 0; i < cs(s1); i++) {
			curhash.first = sum(mult(curhash.first, p.first), s1[i] - '0' + 1);
			curhash.second = sum(mult(curhash.second, p.second), s1[i] - '0' + 1);
			ll t = tohash(curhash);
			if (cost.count(t))
				cost[t] = min(cost[t], c);
			else
				cost[t] = c;
		}
		curhash = mp(0, 0);
		for (int i = cs(s1) - 1; i >= 0; i--) {
			ll toadd = s1[i] - '0' + 1;
			add(curhash.first, mult(toadd, pstep[cs(s1)-i-1].first));
			add(curhash.second, mult(toadd, pstep[cs(s1)-i-1].second));
			ll t = tohash(curhash);
			if (cost.count(t))
				cost[t] = min(cost[t], c);
			else
				cost[t] = c;
		}
	}
	vector<ll> dp(n + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (dp[i] == INF)
			continue;
		pair<ll, ll> curhash = mp(0, 0);
		for (int j = i; j < n; j++) {
			curhash.first = sum(mult(curhash.first, p.first), s[j] - '0' + 1);
			curhash.second = sum(mult(curhash.second, p.second), s[j] - '0' + 1);
			ll t = tohash(curhash);
			if (cost.count(t))
				dp[j + 1] = min(dp[j + 1], dp[i] + cost[t]);
		}
	}
	if (dp[n] == INF)
		cout << -1 << endl;
	else
		cout << dp[n] << endl;
	return 0;
}