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

typedef long long ll;

const int MAXN = 5050, MAXL = 50500;
const ll inf = 1e16;
const ll MOD = 1e9 + 7, P = 3;

ll p[MAXL];

struct Word
{
	ll cost;
	string s;
	int len;

	ll h[MAXN];

	void scan()
	{
		scanf(" %lld", &cost);
		cin >> s;
		len = s.length();

		for (int i = 0; i < len; ++i)
		{
			h[i] = 0;
			if (i)
				h[i] = h[i - 1];
			h[i] += p[i] * (s[i] - '0' + 1) % MOD;
 		}
	}

	ll get_hash(int l, int r)
	{
		if (l)
			return (MOD + h[r - 1] - h[l - 1]) % MOD;
		return (h[r - 1]);
	}
};


ll h[MAXL];

ll get_hash(int l, int r)
{
	if (l)
		return (MOD + h[r - 1] - h[l - 1]) % MOD;
	return (h[r - 1]);
}

Word w[MAXN];

string s;
ll d[MAXL];


bool compare(ll h1, ll h2, int pr)
{
	if (pr >= 0)
	{
		h1 = (h1 * p[pr]) % MOD; 
	}
	else
		h2 = (h2 * p[-pr]) % MOD;
	return (h1 == h2);
}


int main()
{
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);

	p[0] = 1;

	for (int i = 1; i < MAXL; ++i)
		p[i] = (p[i - 1] * P) % MOD;

	int n, m, L;
	scanf("%d%d%d", &m, &n, &L);

	cin >> s;

	for (int i = 0; i < m; ++i)
	{
		h[i] = 0;
		if (i)
			h[i] = h[i - 1];
		h[i] += p[i] * (s[i] - '0' + 1) % MOD;
		}

	for (int i = 0; i < n; ++i)
		w[i].scan();

	fill(d, d + m + m, inf);

	d[0] = 0;


	for (int i = 0; i < m; ++i)
	{
		if (d[i] == inf)
			break;
		for (int j = 0; j < n; ++j)
		{
			for (int k = 0; k < w[j].len && i + k < m; ++k)
			{
				if (s[i + k] != w[j].s[k])
					break;
				else
					d[i + k + 1] = min(d[i + k + 1], d[i] + w[j].cost);
			}
			for (int k = 0; k < w[j].len && i + k <= m; ++k)
			{
				if (compare(get_hash(i, i + k + 1), w[j].get_hash(w[j].len - k - 1, w[j].len), w[j].len - k - 1 - i))
					d[i + k + 1] = min(d[i + k + 1], d[i] + w[j].cost);
			}
		}
		/*for (int i = 0; i <= m; ++i)
			printf("%lld ", d[i]);
		printf("\n");*/
	}

	if (d[m] == inf)
		d[m] = -1;


	printf("%lld\n", d[m]);



	return 0;
}