/* D_Typing */

#pragma comment(linker, "/STACK:536870912")

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <string>
#include <string.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

#define FOR(i, s, f) for (int i = (s); i < (f); ++i)
#define ROF(i, f, s) for (int i = (f) - 1; i >= (s); --i)
#define forn(i, f) for (int i = 0; i < (f); ++i)
#define rofn(i, f) for (int i = (f) - 1; i >= 0; --i)
#define forit(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef const int cint;
typedef long double ld;
#define pi pair < int, int >
#define vi vector < int >

#define TASK "typing"

cint N = 5e3 + 3;
cint INF = 1e9;

int m, n, L;
string str;
string w[N];
int c[N];

int dp[N][N];

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

//	cout.precision(30);

	cin >> m >> n >> L;
	cin >> str;
	forn(i, n)
		cin >> c[i] >> w[i];

	forn(i, m + 1)
	{
		forn(j, m + 1)
			dp[i][j] = INF;
	}

	FOR(i, 1, m + 1)
		dp[i][i - 1] = 0;

	ROF(i, m + 1, 1)
	{
		FOR(j, i, m + 1)
		{
			FOR(k, i, j)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);

			forn(k, n)
			{
				FOR(beg, i, j + 1)
				{
					int t;
					for (t = beg; t < j + 1 && t - beg < w[k].length() && w[k][t - beg] == str[t - 1]; ++t) {}
					dp[i][j] = min(dp[i][j], dp[i][beg - 1] + c[k] + dp[t][j]);
				}
				FOR(end, i, j + 1)
				{
					int t;
					for (t = end; t >= i && end - t < w[k].length() && w[k][w[k].length() - (end - t) - 1] == str[t - 1]; --t) {}
					dp[i][j] = min(dp[i][j], dp[i][t] + c[k] + dp[end + 1][j]);
				}
			}
		}
	}

	cout << (dp[1][m] == INF ? -1 : dp[1][m]) << endl;

	fclose(stdin);
	fclose(stdout);
	return 0;
}
