#include <bits/stdc++.h>
using namespace std;

#define NAME "typing"
#define long long long

const long inf = 1488228228148822822ll;


struct trie {
	long val;
	trie* *next;

	trie(long val) {
		this->val = val;
		next = new trie*[2];
		next[0] = next[1] = nullptr;
	}
};

template<class Iter>
void trie_add(trie *t, Iter first, Iter last, int p) {
	if (first == last) return;
	int c = *first - '0';
	if (!t->next[c])
		t->next[c] = new trie(p);
	if (t->next[c]->val > p)
		t->next[c]->val = p;
	trie_add(t->next[c], ++first, last, p);
}


int main() {
#ifndef NO_FILES
	freopen(NAME".in", "r", stdin);
	freopen(NAME".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int m, n, l;
	cin >> m >> n >> l;
	string s; cin >> s;
	vector<string> t(n);
	vector<long> c(n);
	int lmax = 0;
	for (int i = 0; i < n; ++i) {
		cin >> c[i] >> t[i];
		lmax = max(lmax, (int)t[i].length());
	}

	if (n <= 200 and false) {
		exit(1);
	} else if (lmax <= 2000) {
		trie *tr = new trie(1488);
		for (int i = 0; i < n; ++i)	{
			trie_add(tr, t[i].begin(), t[i].end(), c[i]);
			trie_add(tr, t[i].rbegin(), t[i].rend(), c[i]);
		}
		vector<long> dp(m, inf);
		for (int i = 0; i < m; ++i) {
			trie *ct = tr;
			long cdp = (i == 0) ? 0 : dp[i - 1];
			if (cdp < 0) continue;
			for (int j = i; j < m; ++j) {
				int cc = s[j] - '0';
				if (!ct->next[cc])
				 	break;
				ct = ct->next[cc];
				dp[j] = min(dp[j], cdp + ct->val);
			}
			if (dp[i] == inf)
				dp[i] = -1;
		}
		cout << dp[m - 1] << endl;
	} else {
		exit(1);
	}
}

