#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <vector>
#include <string>

using namespace std;

const int INF = 1000000000;
const int N = 300000;
int dp[N];
string p[N];
int cost[N];

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

	int m, n, l;
	cin >> m >> n >> l;
	string s;
	cin >> s;
	s = ' ' + s;

	for (int i = 0; i < n; i++) {
		cin >> cost[i];
		cin >> p[i];
	}
	dp[0] = 0;
	for (int i = 1; i <= m; i++) {
		dp[i] = INF;
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= i; j++) {
			for (int h = 0; h < n; h++) {
				bool prov = true;
				for (int a = j; a <= i; a++) {
					if (a - j >= (int)p[h].size() || p[h][a - j] != s[a]) {
						prov = false;
					}
				}
				if (prov) {
					dp[i] = min(dp[j - 1] + cost[h], dp[i]);
				}
				prov = true;
				for (int a = i; a >= j; a--) {
					if ((int)p[h].size() - 1 + a - i < 0 || p[h][p[h].size() - 1 + a - i] != s[a]) {
						prov = false;
					}
				}
				if (prov) {
					dp[i] = min(dp[j - 1] + cost[h], dp[i]);
				}
			}
		}
	}

	if (dp[m] >= INF) {
		cout << -1 << endl;
	}
	else {
		cout << dp[m] << endl;
	}
	//for (;;);
}

/*

9 2 8
000110100
1 100
1 11001

3 1 3
100 
1 101

*/
