#define _ijps 0
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <set>
#include <vector>
#include <time.h>
#include <unordered_map>

using namespace std;

#define name "typing"
typedef long long ll;
#define forn(i, n) for(int i = 0; i < n; i++)
#define fornn(i, a, n) for(int i = a; i < n; i++)
#define mk make_pair

const int dd = 1e5 + 7;
const int infi = 1e9 + 7;
const ll inf = 1e18 + 7;
const ll mod1 = 1e9 + 7;
const ll mod2 = 1e9 + 23;

const ll p1 = 5;
const ll p2 = 31;

int m, n, L;
string s;

ll H1[dd], P1[dd];
ll H2[dd], P2[dd];

ll geth1(int l, int r) {
	ll a = H1[r + 1];
	ll b = H1[l];
	b = b * P1[r - l + 1] % mod1;
	a = (a - b + mod1) % mod1;
	return a;
}

ll geth2(int l, int r) {
	ll a = H2[r + 1];
	ll b = H2[l];
	b = b * P2[r - l + 1] % mod2;
	a = (a - b + mod2) % mod2;
	return a;
}


unordered_map<ll, int> Ce(5000000);

ll go(ll a, ll b) {
	return (a << 31ll) + b;
}

int main() {
	if (_ijps) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
	else {
		freopen(name".in", "r", stdin);
		freopen(name".out", "w", stdout);
	}
	
	cin >> m >> n >> L >> s;
	int g = 0;
	P1[0] = 1;
	forn(i, dd - 1) {
		P1[i + 1] = (P1[i] * p1) % mod1;
	}
	forn(i, m) {
		H1[i + 1] = (H1[i] * p1 + s[i] - '0' + 1) % mod1;
	}
	P2[0] = 1;
	forn(i, dd - 1) {
		P2[i + 1] = (P2[i] * p2) % mod2;
	}
	forn(i, m) {
		H2[i + 1] = (H2[i] * p2 + s[i] - '0' + 1) % mod2;
	}

	forn(i, n) {
		int c;
		string t;
		cin >> c >> t;
		g = max(g, (int)t.size());
		ll h1 = 0;
		ll h2 = 0;
		forn(i, t.size()) {
			h1 = (h1 * p1 + t[i] - '0' + 1) % mod1;
			h2 = (h2 * p2 + t[i] - '0' + 1) % mod2;
			if (Ce.count(go(h1, h2))) {
				Ce[go(h1, h2)] = min(Ce[go(h1, h2)], c);
			}
			else
				Ce[go(h1, h2)] = c;
		}
		h1 = 0;
		h2 = 0;

		for (int i = t.size() - 1; i >= 0; i--){
			h1 = (h1 + (t[i] - '0' + 1) * P1[t.size() - i - 1]) % mod1;
			h2 = (h2 + (t[i] - '0' + 1) * P2[t.size() - i - 1]) % mod2;
			if (Ce.count(go(h1, h2))) {
				Ce[go(h1, h2)] = min(Ce[go(h1, h2)], c);
			}
			else
				Ce[go(h1, h2)] = c;
		}
	}

	if (g <= 2000) {
		vector<ll> dp(m + 1, inf);
		dp[0] = 0;
		forn(i, m) {
			fornn(j, 1, g + 1) {
				if (i + j <= m) {
					ll h1 = geth1(i, i + j - 1);
					ll h2 = geth2(i, i + j - 1);
					if (Ce.count(go(h1, h2))) {
						dp[i + j] = min(dp[i + j], dp[i] + Ce[go(h1, h2)]);
					}
				}
			}
		}
		if (dp[m] >= inf) {
			cout << -1;
		}
		else {
			cout << dp[m];
		}
	}
}