#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const ll lot = 1e+18;
const int limm = 50001;
const int liml = 50001;
const int limn = liml;

ll max(ll a, ll b) {
	return (a > b ? a : b);
}

ll min(ll a, ll b) {
	return (a < b ? a : b);
}

int slen, n;
char s[limm];
ll dp[limm];
char sam[liml + limn];
int start[limn];
int len[limn];
int cost[limn];

struct Trie {
	Trie *ref[2];
	ll val;
	Trie() : val(lot) {
		ref[0] = NULL;
		ref[1] = NULL;
	}
	void add(int l, int r, ll x) {
		val = min(val, x);
		if (l == r)
			return;
		if (sam[l] == '1') {
			if (!ref[1])
				ref[1] = new Trie();
			ref[1]->add(l + (l < r ? 1 : -1), r, x);
		}
		else {
			if (!ref[0])
				ref[0] = new Trie();
			ref[0]->add(l + (l < r ? 1 : -1), r, x);
		}
	}
};

Trie suff;
Trie pref;

int main() {
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	int i, j, pingas, next = 0;
	int maxl = 0;
	scanf("%d %d %d", &slen, &n, &pingas);
	scanf("%s", &s);
	/*for (i = 0; i < slen; ++i) {
		hashs[i] = ((i ? hashs[i - 1] : 0) * prime + s[i] - '0' + 1) % inf;
		pows[i] = (i ? (pows[i - 1] * prime) % inf : 1);
	}*/

	for (i = 0; i < n; ++i) {
		scanf("%d %s", &cost[i], (sam + next));
		start[i] = next;
		next += strlen(sam + next) + 1;
		len[i] = next - start[i] - 1;
		maxl = max(maxl, len[i]);
		pref.add(start[i], start[i] + len[i], cost[i]);
		suff.add(start[i] + len[i] - 1, start[i] - 1, cost[i]);
	}
	/*for (i = 0; i < n; ++i) {
		ll curhash = 0;
		for (j = 0; j < len[i]; ++j) {
			curhash = (curhash * prime + sam[j + start[i]] - '0' + 1) % inf;
			if (hashes.find(curhash) == hashes.end() || hashes[curhash] > cost[i])
				hashes[curhash] = cost[i];
		}
	}
	for (i = 0; i < n; ++i) {
		ll curhash = 0;
		for (j = len[i] - 1; j >= 0; --j) {
			curhash = (curhash + (sam[j + start[i]] - '0' + 1) * pows[len[i] - 1 - j]) % inf;
			if (hashes.find(curhash) == hashes.end() || hashes[curhash] > cost[i])
				hashes[curhash] = cost[i];
		}
	}*/

	for (i = 0; i < slen; ++i)
		dp[i] = lot;
	for (i = -1; i < slen; ++i) {
		Trie *cur = (&suff);
		for (j = i; j >= 0; --j) {
			cur = cur->ref[s[j] == '1'];
			if (!cur)
				break;
			dp[i] = min(dp[i], (j ? dp[j - 1] : 0) + cur->val);
		}
		cur = (&pref);
		for (j = i + 1; j < slen; ++j) {
			cur = cur->ref[s[j] == '1'];
			if (!cur)
				break;
			dp[j] = min(dp[j], (i + 1 ? dp[i] : 0) + cur->val);
		}
	}
	printf("%lld", (dp[slen - 1] == lot ? -1 : dp[slen - 1]));
	return 0;
}