#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<set>
#include<cassert>
#include<vector>
#include<string>
#include<unordered_map>
using namespace std;
const int MAXN = 300 * 1000 + 7;
const long long INF = (long long)1e18;
string s;
string p[MAXN];
int cost[MAXN];
long long dp[MAXN];
struct node
{
	long long cost;
	node* go[2];
	node()
	{
		cost = INF;
		go[0] = NULL;
		go[1] = NULL;
	}
};
node* root;
void addSuff(string& s, int cost)
{
	node* cur = root;
	for (int i = 0; i < (int)s.length(); i++)
	{
		if (cur->go[s[i] - '0'] == NULL)
		{
			cur->go[s[i] - '0'] = new node();
		}
		cur = cur->go[s[i] - '0'];
		cur->cost = min(cur->cost, (long long)cost);
	}
}
void addPref(string& s, int beg, int cost)
{
	node* cur = root;
	for (int i = beg; i < (int)s.length(); i++)
	{
		if (cur->go[s[i] - '0'] == NULL)
		{
			cur->go[s[i] - '0'] = new node();
		}
		cur = cur->go[s[i] - '0'];
	}
	cur->cost = min(cur->cost, (long long)cost);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	root = new node();
	int m, n, L;
	cin >> m >> n >> L;
	cin >> s;
	s = '#' + s;
	for (int i = 1; i <= n; i++)
	{
		cin >> cost[i] >> p[i];
		reverse(p[i].begin(), p[i].end());
		addSuff(p[i], cost[i]);
		for (int j = 0; j < (int)p[i].length(); j++)
		{
			addPref(p[i], j, cost[i]);
		}
	}
	dp[0] = 0;
	for (int i = 1; i <= m; i++)
	{
		dp[i] = INF;
		node* cur = root;
		for (int j = i; j > 0; j--)
		{
			if (cur->go[s[j] - '0'] == NULL) break;
			cur = cur->go[s[j] - '0'];
			dp[i] = min(dp[i], dp[j - 1] + cur->cost);
		}
	}
	if (dp[m] == INF) dp[m] = -1;
	printf("%lld\n", dp[m]);
}