#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <set>
#include <bitset>
#include <ctime>
#include <unordered_set>

using namespace std;

const int NODES = 1e7;
const int LEN = 1e5;

const int ALP = 2;

struct node
{
	int next[ALP];
	int price;
	node()
	{
		next[0] = next[1] = -1;
		price = 1e9;
	};
};

node t[NODES];
int sz = 1;

void add(const string s, const int price)
{
	int now = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		if (t[now].next[s[i]] == -1)
			t[now].next[s[i]] = sz++;
		now = t[now].next[s[i]];
		if (price > 0)
			if (t[now].price > price)
				t[now].price = price;
	}
	if (price < 0)
		if (t[now].price > -price)
			t[now].price = -price;
}

char ss[LEN];
int dp[5001][LEN];
string build;

int main()
{
	::ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	int n, m, l;
	cin >> n >> m >> l;
	cin >> build;
	for (int i = 0; i < n; ++i)
		build[i] -= '0';
	for (int i = 0; i < m; ++i)
	{
		int p;
		string t;
		cin >> p >> t;
		for (int i = 0; i < t.length(); ++i)
			t[i] -= '0';
		add(t, p);
		for (int j = 1; j < t.length(); ++j)
		{
			add(t.substr(0, j), p);
			add(t.substr(j), -p);
		}
	}
	for (int j = 0; j <= n; ++j)
		for (int i = 0; i < sz; ++i)
			dp[j][i] = 1e9;
	dp[0][0] = 0;
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j < sz; ++j)
			if (dp[i][0] > dp[i][j] + t[j].price)
				dp[i][0] = dp[i][j] + t[j].price;
		if (i < n)
		{
			char go = build[i];
			for (int j = 0; j < sz; ++j)
			{
				if (t[j].next[go] == -1)
					continue;
				if (dp[i + 1][t[j].next[go]] > dp[i][j])
					dp[i + 1][t[j].next[go]] = dp[i][j];
			}
		}
	}
	if (dp[n][0] == 1e9)
		cout << -1 << endl;
	else
		cout << dp[n][0];
	return 0;
}