#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 = 1e5 + 5;
const int LEN = 5e4 + 5;

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 (t[now].price > price)
			t[now].price = price;
	}
}

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

int main()
{
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	int n, m, l;
	scanf("%d %d %d", &n, &m, &l);
	scanf(" %s", ss);
	build = string(ss);
	for (int i = 0; i < n; ++i)
		build[i] -= '0';
	for (int i = 0; i < m; ++i)
	{
		int p;
		scanf("%d %s", &p, ss);
		string t(ss);
		for (int i = 0; i < t.length(); ++i)
			t[i] -= '0';
		for (int i = 1; i <= t.length(); ++i)
		{
			add(t.substr(0, i), p);
			add(t.substr(i - 1), p);
		}
	}
	for (int j = 0; j <= n; ++j)
		for (int i = 0; i < sz; ++i)
			dp[j][sz] = 1e9;
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i)
	{
		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[i + 1][0] > dp[i][j] + t[j].price)
				dp[i + 1][0] = dp[i][j] + t[j].price;
		}
	}
	cout << dp[n][0];
	return 0;
}