#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 = 5e5 + 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] ;
	a = a - b;
	return a;
}


const int rs = 20;
const int siz = (1 << rs) + 5;

struct hs {
	vector<int> Te;
	vector<ll> He;

	void reb(int siz = ::siz) {
		Te.resize(siz);
		He.resize(siz);
		forn(i, siz) {
			He[i] = -1;
			Te[i] = infi;
		}
	}

	void up(ll a, int c) {
		int t;
		if (Te.size() == siz) {
			t = a & ((1 << rs) - 1);
		}
		else {
			t = a % Te.size();
		}
		while (1) {
			if (He[t] == a) {
				Te[t] = min(Te[t], c);
				return;
			}
			if (He[t] < 0) {
				He[t] = a;
				Te[t] = c;
				return;
			}
			t++;
			if (t == Te.size()) {
				t = 0;
			}
		}
	}
	int get(ll a) {
		int t;
		if (Te.size() == siz) {
			t = a & ((1 << rs) - 1);
		}
		else {
			t = a % Te.size();
		}
		while (1) {
			if (He[t] == a) {
				return Te[t];
			}
			if (He[t] < 0) {
				return infi;
			}
			t++;
			if (t == Te.size()) {
				t = 0;
			}
		}
	}
} Ce;

ll go(ll a, ll b) {
	ll t = (a << 31ll) + b;
	if (t < 0)
		t *= -1;
	return t;
}


ll F[dd * 4];

void push(int v) {
	F[v * 2] = min(F[v * 2], F[v]);
	F[v * 2 + 1] = min(F[v * 2 + 1], F[v]);
}

ll get(int v, int l, int r, int x) {
	if (l == r) {
		return F[v];
	}
	push(v);
	int s = (l + r) / 2;
	if (x <= s) {
		return get(v * 2, l, s, x);
	}
	else {
		return get(v * 2 + 1, s + 1, r, x);
	}
}

void up(int v, int l, int r, int lq, int rq, ll x) {
	if (lq > rq) {
		return;
	}
	if (l == lq && r == rq) {
		F[v] = min(F[v], x);
		return;
	}
	push(v);
	int s = (l + r) / 2;
	up(v * 2, l, s, lq, min(rq, s), x);
	up(v * 2 + 1, s + 1, r, max(lq, s + 1), rq, x);
}


struct seg {
	ll F[dd * 4];
	void up(int v, int l, int r, int x, ll t) {
		if (l == r) {
			F[v] = t;
			return;
		}
		int s = (l + r) / 2;
		if (x <= s) {
			up(v * 2, l, s, x, t);
		}
		else {
			up(v * 2 + 1, s + 1, r, x, t);
		}
		F[v] = min(F[v * 2], F[v * 2 + 1]);
	}
	ll get(int v, int l, int r, int lq, int rq) {
		if (lq > rq) {
			return inf;
		}
		if (l == lq && r == rq) {
			return F[v];
		}

		int s = (l + r) / 2;
		return min(get(v * 2, l, s, lq, min(rq, s)),
			get(v * 2 + 1, s + 1, r, max(lq, s + 1), rq));
	}
} Z;

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);
	}

	if (0) {
		int m = 100;
		int n = 50;
		cout << m << ' ' << n << ' ' << n << '\n';
		forn(i, m) {
			char c = rand() % 2 + '0';
			cout << c;
		}
		cout << '\n';
		forn(i, n) {
			cout << rand() % 100 + 1 << ' ';
			string g;
			int t = rand() % 100 + 1;
			forn(j, t) {
				char c = rand() % 2 + '0';
				cout << c;

			}
			cout << '\n';
		}
		return 0;

	}

	cin >> m >> n >> L >> s;
	m = s.size();
	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);
	}
	forn(i, m) {
		H2[i + 1] = (H2[i] * p2 + s[i] - '0' + 1) ;
	}

	vector<pair<int, string> > E;

	forn(i, n) {
		int c;
		string t;
		cin >> c >> t;
		E.push_back(mk(c, t));
		g = max(g, (int)t.size());
	}

	Ce.reb();
	forn(i, n) {
		int c = E[i].first;
		string t = E[i].second;
		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);
			Ce.up(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]);
			Ce.up(go(h1, h2), c);
		}
	}
	if (g <= 2000 && 01) {

		vector<ll> dp(m + 1, inf);
		dp[0] = 0;
		forn(i, m) {
			ll h1, h2;
			h1 = h2 = 0;
			fornn(j, 1, g + 1) {
				if (i + j <= m) {
					h1 = (h1 * p1 + s[i + j - 1] - '0' + 1);
					h2 = (h2 * p2 + s[i + j - 1] - '0' + 1);
					if (h1 >= mod1) {
						h1 %= mod1;
					}
					int te = Ce.get(go(h1, h2));
					if (te != infi) {
						dp[i + j] = min(dp[i + j], dp[i] + te);
					}
				}
			}
		}
		forn(i, m + 1) {
			if (_ijps)cout << dp[i] << ' ';
		}
		if (dp[m] >= inf) {
			cout << -1;
		}
		else {
			cout << dp[m];
		}
		return 0;
	}
	else {
		vector<hs> T, RT;
		map<int, int> Q;
		map<int, int> G;
		vector<int> Go;

		forn(i, n) {
			int c = E[i].first;
			string t = E[i].second;
			Go.push_back(c);
			Q[c] += t.size();
			E.push_back(mk(c, t));
		}
		sort(Go.begin(), Go.end());
		Go.resize(unique(Go.begin(), Go.end()) - Go.begin());

		T.resize(Q.size());
		RT.resize(Q.size());
		forn(i, T.size()) {
			G[Go[i]] = i;
			T[i].reb(Q[Go[i]] * 15 + 100);
			RT[i].reb(Q[Go[i]] * 15 + 100);
		}

		forn(i, n) {
			int c = E[i].first;
			string t = E[i].second;
			int gos = G[c];

			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);
				T[gos].up(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]) ;
				RT[gos].up(go(h1, h2), c);
			}
		}

		forn(i, dd * 4) {
			F[i] = inf;
		}
		up(1, 0, dd - 1, 0, 0, 0);
		vector<ll> dp(m + 1, inf);
		dp[0] = 0;

		forn(i, m + 1) {
			ll t = get(1, 0, dd - 1, i);

			dp[i] = min(t, t);

			if (i)forn(j, Go.size()) {
				int l = 0, r = i + 1;
				while (r - l > 1) {
					int s = (l + r) / 2;
					ll h1 = geth1(i - s, i - 1);
					ll h2 = geth2(i - s, i - 1);
					ll c = go(h1, h2);
					int e = RT[j].get(c);
					if (e == infi) {
						r = s;
					}
					else {
						l = s;
					}
				}
				dp[i] = min(dp[i], Z.get(1, 0, dd - 1, i - l, i - 1) + Go[j]);
			}
			if (i == m)
				continue;
			forn(j, Go.size()) {
				int l = 0, r = m - i + 1;
				while (r - l > 1) {
					int s = (l + r) / 2;
					ll h1 = geth1(i, i + s - 1);
					ll h2 = geth2(i, i + s - 1);
					ll c = go(h1, h2);
					int e = T[j].get(c);
					if (e == infi) {
						r = s;
					}
					else {
						l = s;
					}
				}
				up(1, 0, dd - 1, i, i + l, dp[i] + Go[j]);
			}
			Z.up(1, 0, dd - 1, i, dp[i]);
		}
		dp[m] = min(dp[m], get(1, 0, dd - 1, m));

		forn(i, m + 1) {
			if (_ijps)cout << dp[i] << ' ';
		}
		if (dp[m] >= inf) {
			cout << -1;
		}
		else {
			cout << dp[m];
		}
	}
}