#include <iostream>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstring>
#include <tuple>
#include <bitset>
#include <cstdlib>
#include <queue>
#define mp make_pair
#define pb push_back
#define NAME "typing"
#define mt make_tuple
#define y1 y11

using namespace std;

typedef long long ll;
typedef long double ld;

const int nmax = 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ll infl = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
const int force = 27;
const ld pi = acos(-1.0);

string s;
int n, m, L;
queue<int> qu;
int a[nmax][2];
int cost[nmax];
int top = 1;
int suf[nmax], c, len[nmax];
string t;
ll dp[nmax];

void add(string s, int c) {
	int ind = 0;
	cost[ind] = (cost[ind] == 0 ? c : min(cost[ind], c));
	for (int i = 0; i < (int)s.length(); i++) {
		if (a[ind][s[i] - '0'] == 0) {
			len[top] = i + 1;
			a[ind][s[i] - '0'] = top++;
		}
		ind = a[ind][s[i] - '0'];
		cost[ind] = (cost[ind] == 0 ? c : min(cost[ind], c));
	}
}

int main() {
	freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
	cin >> m >> n >> L;
	getline(cin, s);
	getline(cin, s);
	for (int i = 0; i < n; i++) {
		cin >> c >> t;
		add(t, c);
		reverse(t.begin(), t.end());
		add(t, c);
	}
	qu.push(0);
	suf[0] = -1;
	while (qu.size()) {
		int v = qu.front();
		qu.pop();
		for (int i = 0; i < 2; i++) {
			if (a[v][i] == 0) {
				continue;
			}
			qu.push(a[v][i]);
			int index = suf[v];
			while (index != -1 && a[index][i] == 0) {
				index = suf[index];
			}
			if (index == -1) {
				suf[a[v][i]] = 0;
			} else {
				suf[a[v][i]] = a[index][i];
			}
		}
	}
	int ind = 0;
	ll answer = 0;
	for (int i = 0; i <= (int)s.length(); i++) {
		dp[i] = infl;
	}
	dp[0] = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		if (a[ind][s[i] - '0'] == 0) {
			while (ind != -1 && a[ind][s[i] - '0'] == 0) {
				ind = suf[ind];
			}
			if (ind == -1) {
				cout << -1 << endl;
				return 0;
			}
			ind = a[ind][s[i] - '0'];
		} else {
			ind = a[ind][s[i] - '0'];
		}
		int index = ind;
		while (index != -1) {
			dp[i + 1] = min(dp[i + 1], dp[i + 1 - len[index]] + cost[index]);
			index = suf[index];
		}
	}
	cout << dp[(int)s.length()] << endl;
}