#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cassert>

using namespace std;

typedef long long ll;

#define TASK "typing"
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define pk push_back
#define mk make_pair

const int MAXN = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
const ll LINF = (ll)2e18;

int solve();

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#else
	freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	return solve();
}

struct Node {
	int to[2], cost;
	Node(int _cost = INF) {
		to[0] = to[1] = 0;
		cost = _cost;
	}
};

ll c[MAXN], dp[MAXN];
string str[MAXN], revstr[MAXN];
Node bor[MAXN], revbor[MAXN];
int borsz = 1, revborsz = 1;

void add(string &s, Node *t, int cost, int &sz) {
	int v = 0;
	for (char c : s) {
		int x = c - '0';
		if (!t[v].to[x]) {
			t[v].to[x] = sz;
			sz++;
		}
		v = t[v].to[x];
		t[v].cost = min(t[v].cost, cost);
	}
}

void jump(int &v, Node *t, char c, int &cost) {
	int x = c - '0';
	v = t[v].to[x];
	cost = t[v].cost;
}

int solve() {
	int m, n, l;
	cin >> m >> n >> l;
	string s;
	cin >> s;
	s = '#' + s;
	forn(i, n) {
		scanf("%d ", &c[i]);
		cin >> str[i];
		revstr[i] = str[i];
		reverse(all(revstr[i]));

		add(str[i], bor, c[i], borsz);
		add(revstr[i], revbor, c[i], revborsz);
	}

	for1(i, m) {
		dp[i] = LINF;
	}
	bor[0].cost = revbor[0].cost = INF;

	for1(i, m) {
		ll nd = LINF;
		int cost, v = 0;

		for (int j = i; j >= 1; j--) {//suf
			jump(v, revbor, s[j], cost);

			if (v) {
				nd = min(nd, dp[j - 1] + cost);
			}
			else {
				break;
			}
		}

		v = 0;
		for (int j = i; j <= m; j++) {//pref
			jump(v, bor, s[j], cost);

			if (v) {
				dp[j] = min(dp[j], dp[i - 1] + cost);
			}
			else {
				break;
			}
		}

		dp[i] = min(dp[i], nd);
	}

	cout << (dp[m] >= LINF ? -1 : dp[m]);
	return 0;
}