#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
const ll inf = 1000000007;
const ll INF = 8000000000000000000;
const ll mod = 2000000009;
const ll pp = 3;

vector<ll> deg(300005);

void ch(string &s, vector<pair<ll, ll>> &h) {
	h.resize(s.length() + 1);
	for (ll i = 1; i <= s.length(); i++)
		h[i] = make_pair((h[i - 1].first * pp + s[i - 1] - '0' + 1) % mod,
			h[i - 1].second * pp + s[i - 1] - '0' + 1);
}

pair<ll, ll> get(vector<pair<ll, ll>> &h, ll l, ll r) {
	return make_pair((h[r + 1].first + mod * mod - h[l].first * deg[r - l + 1]) % mod,
		h[r + 1].second + mod * mod - h[l].second * deg[r - l + 1]);
}

ll f(pair<ll, ll> ha) {
	return ha.first * mod + ha.second;
}

int main() {
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	deg[0] = 1;
	for (ll i = 1; i <= 300000; i++)
		deg[i] = (deg[i - 1] * pp) % mod;
	ll m, n, L;
	cin >> m >> n >> L;
	string s;
	cin >> s;
	unordered_map<ll, ll> w;
	w.rehash(n);
	while (n--) {
		string t;
		ll c;
		cin >> c >> t;
		vector<pair<ll, ll>> h;
		ch(t, h);
		for (ll i = 0; i < t.length(); i++) {
			pair<ll, ll> ha = get(h, 0, i);
			ll q = f(ha);
			if (!w.count(q)) w[q] = c;
			else w[q] = min(w[q], c);
			ha = get(h, i, t.length() - 1);
			if (!w.count(q)) w[q] = c;
			else w[q] = min(w[q], c);
		}
	}
	vector<pair<ll, ll>> h;
	ch(s, h);
	vector<ll> d(m, INF);
	for (ll i = 0; i < m; i++)
		for (ll j = 0; j <= i; j++) {
			pair<ll, ll> ha = get(h, j, i);
			ll q = f(ha);
			if (w.count(q)) {
				if (j == 0) d[i] = w[q];
				else if (d[j - 1] != INF) d[i] = min(d[i], d[j - 1] + w[q]);
			}
		}
	//for (ll i = 0; i < m; i++)
	//  cout << i << ' ' << d[i] << endl;
	if (d[m - 1] != INF) cout << d[m - 1];
	else cout << -1;
	return 0;
}