#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <cassert>
#include <memory.h>
#include <iomanip>
#include <bitset>

using namespace std;

#define int long long
#define sz(a) (int)(a.size())

const int MAXN = 111;
int dp[MAXN];
string s[MAXN];
int cost[MAXN];
string t;
int m, n, L;
const int INF = 1e18;

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	cin >> m >> n >> L;
	cin >> t;
	for (int i = 1; i <= n; ++i)
	{
		cin >> cost[i] >> s[i];
	}
	dp[0] = 0;
	t = "2" + t;
	for (int i = 1; i < sz(t); ++i)
	{
		dp[i] = INF;
	}
	for (int i = 1; i < sz(t); ++i)
	{
		for (int j = 0; j < i; ++j)
		{
			string cur = t.substr(j + 1, i - j);
			for (int k = 1; k <= n; ++k)
			{
				if (sz(s[k]) < sz(cur))
					continue;
				string z1 = s[k].substr(0, sz(cur));
				string z2 = s[k].substr(sz(s[k]) - sz(cur), sz(cur));
				if (z1 == cur || z2 == cur)
				{
					dp[i] = min(dp[i], dp[j] + cost[k]);
				}
			}
		}
	}
	cout << (dp[sz(t) - 1] == INF ? -1 : dp[sz(t) - 1]);
	return 0;
}