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

using namespace std;

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

const int MAXN = 5555;
int dp[MAXN];
string s[MAXN];
int cost[MAXN];
string t;
int m, n, L;
const int INF = 1e18;
int ht[MAXN];
int temp[MAXN];
int p = rand() + 228, q = 1e9 + 13;
int k = ((1238192347 % p - 13123) % p + 1137) % p;
int deg[MAXN];
unordered_map<int, int> st[MAXN];

void hash_it(string &s, int h[])
{
	for (int i = 1; i < sz(s); ++i)
	{
		h[i] = (h[i - 1] * p + s[i] - '0' + k) % q;
	}
}

int get(int l, int r, int h[])
{
	return (h[r] - h[l - 1] * deg[r - l + 1] + q * q) % q;
}

void process(int len, int c)
{
	for (int i = 1; i <= len; ++i)
	{
		int ha = get(1, i, temp);
		if (!st[i].count(ha))
		{
			st[i][ha] = c;
		}
		else
		{
			st[i][ha] = min(st[i][ha], c);
		}
	}
	for (int i = 1; i <= len; ++i)
	{
		int ha = get(len - i + 1, len, temp);
		if (!st[i].count(ha))
		{
			st[i][ha] = c;
		}
		else
		{
			st[i][ha] = min(st[i][ha], c);
		}
	}
}

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);
	if (k == 0)
		k = 1;
	deg[0] = 1;
	for (int i = 1; i < MAXN; ++i)
	{
		deg[i] = deg[i - 1] * p % q;
	}
	cin >> m >> n >> L;
	cin >> t;
	for (int i = 1; i <= n; ++i)
	{
		cin >> cost[i] >> s[i];
		s[i] = "2" + s[i];
		hash_it(s[i], temp);
		process(sz(s[i]) - 1, cost[i]);
		reverse(s[i].begin(), s[i].end());
		s[i].pop_back();
		s[i] = "2" + s[i];
		hash_it(s[i], temp);
		process(sz(s[i]) - 1, cost[i]);
	}
	dp[0] = 0;
	t = "2" + t;
	hash_it(t, ht);
	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)
		{
			int cur = get(j + 1, i, ht);
			int cs = (st[i - j].count(cur) ? st[i - j][cur] : INF);
			dp[i] = min(dp[i], dp[j] + cs);
		}
	}
	cout << (dp[sz(t) - 1] == INF ? -1 : dp[sz(t) - 1]);
	return 0;
}