#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>

using namespace std;

const int P = 151031, MOD1 = 1e9 + 7, MOD2 = 1e9 + 9, MAXN = 3 * 100000;
int pw1[MAXN + 1], pw2[MAXN + 1], c[MAXN + 1];
long long dp[MAXN + 1];
map<pair<int, int>, long long> cnt;

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;
		pw2[i] = (1LL * pw2[i - 1] * P) % MOD2;
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		string s;
		cin >> s;
		vector<int> h1((int)s.size() + 10, 0);
		vector<int> h2((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;
			h2[i + 1] = (h2[i] + 1LL * pw2[i] * s[i]) % MOD2;
		}
		for (int j = 1; j <= (int)s.size(); j++) {
			int hash1, hash2, hash3, hash4;
			hash1 = (1LL * h1[j] * pw1[5000 - 1]) % MOD1;
			hash2 = (1LL * h2[j] * pw2[5000 - 1]) % MOD2;
			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;
			hash4 = h2[(int)s.size()] - h2[(int)s.size() - j];
			if (hash4 < 0)
				hash4 += MOD2;
			hash4 = (1LL * hash4 * pw2[5000 - ((int)s.size() - j + 1)]) % MOD2;
			if (cnt.find({ hash1, hash2 }) == cnt.end())
				cnt[{hash1, hash2}] = c[i];
			else
				cnt[{hash1, hash2}] = min(cnt[{hash1, hash2}], (long long)c[i]);
			if (make_pair(hash1, hash2) != make_pair(hash3, hash4)) {
				if (cnt.find({ hash3, hash4 }) == cnt.end())
					cnt[{hash3, hash4}] = c[i];
				else
					cnt[{hash3, hash4}] = min(cnt[{hash3, hash4}], (long long)c[i]);
			}
		}
	}
	vector<int> h1((int)s.size() + 10, 0);
	vector<int> h2((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;
		h2[i + 1] = (h2[i] + 1LL * pw2[i] * s[i]) % MOD2;
	}
	for (int i = 1; i <= m; i++)
		dp[i] = 1e18;
	for (int i = 1; i <= m; i++) {
		for (int j = i; j >= 1; j--) {
			int hash1 = h1[i] - h1[j - 1];
			if (hash1 < 0)
				hash1 += MOD1;
			int hash2 = h2[i] - h2[j - 1];
			if (hash2 < 0)
				hash2 += MOD2;
			hash1 = (1LL * hash1 * pw1[5000 - j]) % MOD1;
			hash2 = (1LL * hash2 * pw2[5000 - j]) % MOD2;
			if(cnt[{ hash1, hash2 }])
				dp[i] = min(dp[i], dp[j - 1] + cnt[{ hash1, hash2 }]);
		}
	}
	if (dp[m] < 1e18)
		cout << dp[m] << endl;
	else
		cout << -1 << endl;
	return 0;
}