//#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int l,n, k, a, b, i, c, j, ii, z, a1;
char ch;
bool u;
char m2[400000];
long long dp[400000];
const long long md = 1000000007;
const long long osn = 37;
vector <pair<int, long long> > m3[400000];
long long t[400000];
long long has[400000];
string s1;
pair<int, int> ttt;
struct cmp
{
	bool operator()(const pair<int, int> & a, const pair<int, int> & b) const
	{
		return (a.first < b.first);
	}
};
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	scanf("%d%d%d\n", &k, &n, &l);
	scanf("%s", &m2);
	string s = "5";
	s = s + m2;
	t[0] = 1;
	for (int i = 1; i <= max(l,k); i++)
		t[i] = (t[i - 1] * osn) % md;
	int kol = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%s", &a, &m2);
		s1 = "5";
		s1 = s1+ m2;
		for (int z = 1; z < s1.length(); z++)
			has[z] = (has[z - 1] + (s1[z] + 1)*t[z]) % md;
		for (int z = 1; z < s1.length(); z++)
		{
			long long rr = (has[z] * t[max(l,k) - z]) % md;
			m3[z].push_back(make_pair(rr, a));
			rr =(((has[s1.length() - 1] - has[z - 1] + md)*t[max(l,k) - (s1.length() - 1)])) % md;
			m3[s1.length() - z].push_back(make_pair(rr, a));
		}
	}
	for (int i = 1; i <= l; i++)
	{
		sort(m3[i].begin(), m3[i].end());
		int kol = 0;
		for (int z = 1; z < m3[i].size(); z++)
			if (m3[i][z].first != m3[i][z - 1].first)
			{
				kol++;
				m3[i][kol] = m3[i][z];
			}
			else
				m3[i][kol].second = min(m3[i][kol].second, m3[i][z].second);
		m3[i].resize(kol+1);
	}
	dp[0] = 0;
	for (int i = 1; i <= k; i++)
		has[i] = (has[i - 1] + (s[i] + 1)*t[i]) % md;
	for (int i = 1; i <= k; i++)
	{
		dp[i] = -1;
		for (int z = i; z >= max(1,i-2000); z--)
		{
			if (dp[z - 1] == -1)
				continue;
			pair<int,int> uu = make_pair(((has[i] + md - has[z - 1])*t[max(l,k)-i]) % md,0);
			auto ww = lower_bound(m3[i - z + 1].begin(), m3[i - z + 1].end(), uu, cmp());
			if (ww != m3[i-z+1].end() && ww->first == uu.first)
				if (dp[i] == -1)
					dp[i] = dp[z - 1] + ww->second;
				else
					dp[i] = min(dp[i], dp[z - 1] + ww->second);
		}
	}
	printf("%I64d", dp[k]);
	return 0;
}