#include <string>
#include <unordered_set>
#include <random>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#pragma comment(linker, "/STACK:512000000")

#define lint long long

using namespace std;

const int maxn = 300010;
const int maxm = 300010;
const int maxl = 300010;

struct nod {
	nod* ch[2] = {};
	lint cost = INT_MAX;
};

void dfs(string& str, int pos, nod* now, lint c) {
	if (pos >= str.size())
		return;
	now->cost = min(c, now->cost);
	if (now->ch[(str[pos] == '1')] == 0) 
		now->ch[(str[pos] == '1')] = new nod;
	dfs(str, pos + 1, now->ch[(str[pos] == '1')], c);
}

const lint hmod = (lint)30 * ((lint)1 << 30) - 1;
const lint hp = 37;
const lint hadd = 228;
const lint hm = 47;

void hasher(vector<bool> &v, vector<int> &h) {
	h.resize(v.size() + 1);
	h[0] = 0;
	for (int i = 0; i < v.size(); i++) {
		h[i + 1] = (h[i] * hp + (v[i] * hm + hadd)) % hmod;
	}
}

int32_t main() {
	ifstream cin("typing.in");
	ofstream cout("typing.out");
	ios::sync_with_stdio(false);

	int n, m, l;
	cin >> m >> n >> l;
	string s;// [maxn];
	cin >> s;
	//for (int i = 0; i < m; i++) {
	//	char c;
	//	cin >> c;
	//	s[i] = c == '1';
	//}

	//lint cost[maxl * 4];
	//for (int i = 0; i < maxl * 4; i++)
	//	cost[i] = 2147483647;//INT_MAX
	//
	//nod root;
	//root.cost = 0;
	
	map<string, lint> cst;
	for (int i = 0; i < n; i++) {
		lint c;
		cin >> c;
		string str;
		cin >> str;
		string q = "";

		for (int i = 0; i < str.size(); i++) {
			//q *= hp;
			//q = (q + hadd + hm * (str[i] == '1')) % hmod;
			q.push_back(str[i]);
			if (!cst.count(q))
				cst[q] = INT_MAX;
			cst[q] = min(cst[q], c);
		}

		q = "";
		lint pow = 1;
		for (int i = str.size() - 1; i >= 0; i--) {
			//q = (q + (hadd + hm * (str[i] == '1')) * pow) % hmod;
			//pow = (pow * hp) % hm;
			q = "";
			for (int k = i; k < str.size(); k++) q.push_back(str[k]);
			if (!cst.count(q))
				cst[q] = INT_MAX;
			cst[q] = min(cst[q], c);
		}
		//dfs(str, 0, &root, c);
		////reverse(str.begin(), str.end());
		//dfs(str, 0, &root, c);
	}

	lint h[maxm + 1];
	lint hppow[maxm + 1];
	hppow[0] = 1;
	h[0] = 0;
	for (int i = 0; i < m; i++) {
		hppow[i + 1] = (hppow[i] * hp) % hmod;
		h[i + 1] = (h[i] * hp + hadd + hm * s[i]) % hmod;
	}

	//reverse(s, s + m);
	vector<lint> ans(m + 1, INT_MAX);
	ans[0] = 0;
	for (int i = 0; i < m; i++) {
		//nod* now = &root;
		//int pos = i;
		//while (pos >= 0 && now->ch[s[pos]] != 0) {
		//	now = now->ch[s[pos]];
		//	ans[i + 1] = min(ans[i + 1], now->cost + ans[pos]);
		//	pos--;
		//}
		for (int j = i; j >= 0; j--) {
			//lint hh = (hmod + h[i + 1] - (h[j] * hppow[i - j + 1]) % hmod) % hmod;	// hash [j i]

			string hh = "";
			for (int k = j; k <= i; k++) hh.push_back(s[k]);
			if (cst.count(hh))
				ans[i + 1] = min(ans[i + 1], cst[hh] + ans[j]);
		}
	}

	if (ans.back() < INT_MAX)
		cout <<  ans.back();
	else cout << -1;

	return 0;
}