#define fname "typing"

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

#include <vector>
#include <map>
#include <set>
#include <string>
#include <unordered_map>



#define forn(i, n) for (ll i = 0; i < n; i ++)
#define fornn(i, m, n) for (ll i = m; i < n; i ++)

#define inb push_back
#define mk make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;

const ll dd = 4e5;
const ll inf = 1e15;
const ll mod = 1e9 + 7;

vector<pair<ll, string> > qwe;

ll dp[dd];

unordered_map<ll, ll> asd;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
#endif
	ll m, n, L;
	cin >> n >> m >> L;
	string str;
	cin >> str;
	n = str.size();
	forn(i, m) {
		ll w;
		cin >> w;
		string s;
		cin >> s;
		ll hs = 0;
		ll step = 1;
		forn(j, s.size()) {
			hs += (s[j] - '0' + 1) * step;
			hs %= mod;
			step *= 31ll;
			step %= mod;
			if (!asd.count(hs))
				asd[hs] = w;
			else
				asd[hs] = min(asd[hs], w);
		}
		hs = 0;
		forn(j, s.size()) {
			hs *= 31ll;
			hs %= mod;
			hs += s[s.size() - j - 1] - '0' + 1;
			hs %= mod;
			if (!asd.count(hs))
				asd[hs] = w;
			else
				asd[hs] = min(asd[hs], w);
		}
	}

	dp[0] = 0;
	forn(i, n)
		dp[i + 1] = inf;



	fornn(i, 1, n + 1) {
		ll hs = 0;
		forn(j, i){
			hs = hs * 31ll;
			hs %= mod;
			hs += str[i - j - 1] - '0' + 1;
			hs %= mod;
			if (asd.count(hs))
				dp[i] = min(dp[i], asd[hs] + dp[i - j - 1]);
		}
	}
	if (dp[n] == inf)
		cout << -1;
	else
		cout << dp[n];
	return 0;
}