#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);

int top = 0;
ll cost[nmax], c[nmax];
string t[nmax];
int len[nmax];
vector<pair<int, int> > goa[nmax], go[nmax];
int suf[nmax];
int a[nmax][2];
queue<int> qu;
ll dp[nmax];

void init(int a[][2], int suf[]) {
	top = 1;
	for (int i = 0; i < nmax; i++) {
		a[i][0] = a[i][1] = 0;
		suf[i] = 0;
		cost[i] = 0;
		len[i] = 0;
	}
}

void add(int a[][2], const string &s, ll c) {
	int ind = 0;
	cost[ind] = (cost[ind] == 0 ? c : min(cost[ind], c));
	len[0] = 0;
	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 n, m, L;
string s;

void done(vector<pair<int, int> > go[]) {
	init(a, suf);
	for (int i = 0; i < n; i++) {
		add(a, t[i], c[i]);
	}
	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;
	for (int i = 0; i < (int)s.length(); i++) {
		while (ind != -1 && a[ind][s[i] - '0'] == 0) {
			ind = suf[ind];
		}
		if (ind == -1) {
			ind = 0;
		} else {
			ind = a[ind][s[i] - '0'];
		}
		int index = ind;
		while (index > 0) {
			go[i + 1].pb(mp(i + 1 - len[index], cost[index]));
			index = suf[index];
		}
	}
}

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[i] >> t[i];
	}

	for (int i = 0; i < n; i++) {
		reverse(t[i].begin(), t[i].end());
	}
	reverse(s.begin(), s.end());

	done(goa);

	for (int i = 0; i < n; i++) {
		reverse(t[i].begin(), t[i].end());
	}
	reverse(s.begin(), s.end());

	/*for (int i = 0; i <= (int)s.length(); i++) {
		cerr << "MOMENT " << i << endl;
		for (auto v : goa[i]) {
			cerr << v.first << " " << v.second << endl;
		}
	}*/

	for (int i = 0; i <= s.length(); i++) {
		for (int j = 0; j < (int)goa[i].size(); j++) {
			go[(int)s.length() - goa[i][j].first].pb(mp((int)s.length() - i, goa[i][j].second));		
		}	
	}

	/*for (int i = 0; i <= (int)s.length(); i++) {
		cerr << "MOMENT " << i << endl;
		for (auto v : go[i]) {
			cerr << v.first << " " << v.second << endl;
		}
	}*/

	done(go);
	for (int i = 0; i <= (int)s.length(); i++) {
		dp[i] = infl;
	}
	dp[0] = 0;
	for (int i = 1; i <= (int)s.length(); i++) {
		for (auto v : go[i]) {
			dp[i] = min(dp[i], dp[v.first] + v.second);
        }
	}
	cout << (dp[(int)s.length()] == infl ? -1 : dp[(int)s.length()]) << endl;
}