#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <initializer_list>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
time_t _timer;

void _pre()
{
	_timer = clock();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifdef ANDREIKKAA
	assert(freopen("input.txt", "r", stdin) != nullptr);
	//freopen("output.txt", "w", stdout);
#else
	assert(freopen("typing.in", "r", stdin) != nullptr);
	assert(freopen("typing.out", "w", stdout) != nullptr);
#endif
}

void _post()
{
#ifdef ANDREIKKAA
	cout << "\n\n\nTime: " << (clock() - _timer) / (ld)CLOCKS_PER_SEC << endl;
	while (228);
#endif
}

const int MAX_L = 400 * 1000 + 228;
ll cost[MAX_L];
ll INF = 1000LL * 1000 * 1000 * 1000 * 1000;
ll dp[MAX_L];
int suf_pos[MAX_L];
int pos_suf[MAX_L];
int lcp[MAX_L];
bool prf[MAX_L];
int suf[MAX_L];

inline int get_lcp(string::iterator s, string::iterator t, string::iterator e)
{
	int ans = 0;
	while (s != e and t != e and *s == *t)
		++s, ++t, ++ans;
	return ans;
}

inline bool f(string::iterator s, string::iterator t, string::iterator e)
{
	int l = get_lcp(s, t, e);
	t += l;
	s += l;
	if (t == e)
		return false;
	if (s == e)
		return true;
	return *s < *t;
}

void _solve()
{
	fill(dp, dp + MAX_L, INF);
	int m, n, L;
	cin >> m >> n >> L;

	if (m > 10000)
		assert(false);
	string s;
	cin >> s;

	fill(cost, cost + MAX_L, INF);
	s += rand() % 256;
	for (int i = 0; i < n; ++i)
	{
		ll c;
		cin >> c;
		string t;
		cin >> t;
		fill(cost + s.size(), cost + s.size() + t.size(), c);
		prf[s.size()] = true;
		for (int j = 0; j < t.size(); ++j)
			suf[s.size() + j] = t.size() - j;
		s += t;
		s += rand() % 256;
	}

	/*cout << s << endl;
	for (int i = 0; i < s.size(); ++i)
	{
		cout << prf[i];
	}
	cout << endl;
	for (int i = 0; i < s.size(); ++i)
	{
		cout << suf[i];
	}
	cout << endl;*/

	iota(pos_suf, pos_suf + s.size(), 0);
	sort(pos_suf, pos_suf + s.size(), [&](const int a, const int b) {
		return f(s.begin() + a, s.begin() + b, s.begin() + s.size());
	});

	for (int i = 0; i < s.size(); ++i)
	{
		//cout << i << " " << pos_suf[i] << " " << s.substr(pos_suf[i]) << endl;
		suf_pos[pos_suf[i]] = i;
	}
	for (int i = 0; i + 1 < s.size(); ++i)
	{
		int a = pos_suf[i];
		int b = pos_suf[i + 1];
		lcp[i] = get_lcp(s.begin() + a, s.begin() + b, s.begin() + s.size());
		//cout << i << " " << lcp[i] << endl;
	}

	dp[0] = 0;
	for (int i = 1; i <= m; ++i)
	{
		int pos = suf_pos[i - 1];
		int len = 228228228;
		vector<pair<ll, int>> cst;
		cst.reserve(MAX_L);
		for (int j = pos - 1; j >= 0; --j)
		{
			len = min(len, lcp[j]);
			if (cost[pos_suf[j]] != INF and (prf[pos_suf[j]] or suf[pos_suf[j]] <= len))
			{
				cst.push_back({ cost[pos_suf[j]] , len });
			}
		}
		len = 228228228;
		for (int j = pos; j < s.size(); ++j)
		{
			len = min(len, lcp[j]);
			if (cost[pos_suf[j + 1]] != INF and (prf[pos_suf[j + 1]] or suf[pos_suf[j + 1]] <= len))
			{
				cst.push_back({ cost[pos_suf[j + 1]] , len });
			}
		}
		sort(cst.begin(), cst.end(), [](const pair<ll, int> &a, const pair<ll, int> &b) {
			if (a.first != b.first)
				return a.first < b.first;
			return a.second > b.second;
		});
		vector<pair<ll, int>> st;
		for (auto i : cst)
		{
			if (st.empty() or st.back().second < i.second)
			{
				st.push_back(i);
			}
		}
		int ptr = 0;
		for (int j = i; j <= m; ++j)
		{
			while(ptr < st.size() and j - i + 1 > st[ptr].second) //?
				++ptr;
			if (ptr == st.size())
				break;
			dp[j] = min(dp[j], dp[i - 1] + st[ptr].first);
		}
		/*for (int j = 1; j <= m; ++j)
		{
			cout << dp[j] << " ";
		}
		cout << endl;*/
	}
	//cout << endl;

	if (dp[m] == INF)
		dp[m] = -1;
	cout << dp[m] << endl;
}

int main()
{
	_pre();
	_solve();
	_post();
}