#include <iostream>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <iterator>
#include <ctime>
#include <cmath>
#include <fstream>
#include <stdio.h>
#include <assert.h>
#include <bitset>
#include <unordered_map>

using namespace std;

const int P = 151031, MOD1 = 1e9 + 7, MAXN = 5000;
int pw1[MAXN + 1], pw2[MAXN + 1], c[MAXN + 1];
long long dp[MAXN + 1];
map<int, int> cnt;
vector<pair<int, int> > res;

int main() {
	ios_base::sync_with_stdio(false);
	ifstream cin("typing.in");
	ofstream cout("typing.out");

	int m, n, l;
	cin >> m >> n >> l;
	assert(m <= 5000 && l <= 5000);
	string s;
	cin >> s;
	pw1[0] = pw2[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		pw1[i] = (1LL * pw1[i - 1] * P) % MOD1;
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		string s;
		cin >> s;
		vector<int> h1((int)s.size() + 10, 0);
		for (int i = 0; i < (int)s.size(); i++) {
			h1[i + 1] = (h1[i] + 1LL * pw1[i] * s[i]) % MOD1;
		}
		for (int j = 1; j <= (int)s.size(); j++) {
			int hash1, hash2, hash3, hash4;
			hash1 = (1LL * h1[j] * pw1[5000 - 1]) % MOD1;
			hash3 = h1[(int)s.size()] - h1[(int)s.size() - j];
			if (hash3 < 0)
				hash3 += MOD1;
			hash3 = (1LL * hash3 * pw1[5000 - ((int)s.size() - j + 1)]) % MOD1;
			if (cnt.find(hash1) == cnt.end())
				cnt[hash1] = c[i];
			else
				cnt[hash1] = min(cnt[hash1], c[i]);
			if (hash1 != hash3) {
				if (cnt.find(hash3) == cnt.end())
					cnt[hash3] = c[i];
				else
					cnt[hash3] = min(cnt[hash3], c[i]);
			}
		}
	}
	for (auto it : cnt)
		res.push_back({ it.first, it.second });
	sort(res.begin(), res.end());
	vector<int> h1((int)s.size() + 10, 0);
	for (int i = 0; i < (int)s.size(); i++) {
		h1[i + 1] = (h1[i] + 1LL * pw1[i] * s[i]) % MOD1;
	}
	for (int i = 1; i <= m; i++)
		dp[i] = 1e18;
	for (int i = 1; i <= m; i++) {
		for (int j = i; j >= 1 && j - i + 1 <= 1000; j--) {
			int hash1 = h1[i] - h1[j - 1];
			if (hash1 < 0)
				hash1 += MOD1;
			hash1 = (1LL * hash1 * pw1[5000 - j]) % MOD1;
			int cost = -1;
			auto it = lower_bound(res.begin(), res.end(), make_pair(hash1, 0));
			if (it != res.end() && it->first == hash1)
				cost = it->second;
			if (cost != -1)
				dp[i] = min(dp[i], dp[j - 1] + cost);
		}
	}
	if (dp[m] < 1e18)
		cout << dp[m] << endl;
	else
		cout << -1 << endl;
	return 0;
}