#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <time.h>
#pragma warning(disable: 4996)
typedef long long ll;
typedef long double ld;
using namespace std;

const ll SZ = 1e5;
const ll INF = 1e15;

ll d[SZ], c;
string st, x;

struct vertex {
	ll cost;
	vertex *l, *r;
	vertex() {
		l = r = NULL;
		cost = INF;
	}
};
vertex *t = new vertex();

void add(vertex *t, ll p) {
	t->cost = min(t->cost, c);
	if (p == x.size())
		return;
	if (x[p] == '0') {
		if (!t->l)
			t->l = new vertex();
		add(t->l, p + 1);
	} else {
		if (!t->r)
			t->r = new vertex();
		add(t->r, p + 1);
	}
}

void update(vertex *t, ll p, ll add) {
	d[p] = min(d[p], add + t->cost);
	if (st[p] == '0' && t->l)
		update(t->l, p + 1, add);
	if (st[p] == '1' && t->r)
		update(t->r, p + 1, add);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("twopaths.in", "r", stdin);
	freopen("twopaths.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	srand(654536633);

	ll n, m, l;
	cin >> n >> m >> l >> st;
	for (ll i = 0; i < m; i++) {
		cin >> c >> x;
		add(t, 0);
		reverse(x.begin(), x.end());
		add(t, 0);
	}

	for (ll i = 1; i <= n; i++)
		d[i] = INF;
	for (ll i = 0; i < n; i++)
		update(t, i, d[i]);

	cout << (d[n] == INF ? -1 : d[n]);
	
	return 0;
}