#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

const int MAXT = 2000;

int bor[100100][2];
long long borc[100100];
int cnt = 1;

void add(string s, long long st)
{
	int pos = 0;
	for (int i = 0; i < (int)s.size(); i++)
	{
		if (bor[pos][s[i] - '0'] == -1)
		{
			bor[pos][s[i] - '0'] = cnt;
			cnt++;
		}
		borc[bor[pos][s[i] - '0']] = min(borc[bor[pos][s[i] - '0']], st);
		pos = bor[pos][s[i] - '0'];
	}
}

long long d[300000];

int main()
{
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	for (int i = 0; i < 100000; i++)
	{
		d[i] = 1e17;
		borc[i] = 1e17;
		bor[i][1] = -1;
		bor[i][0] = -1;
	}
	borc[0] = 0;
	d[0] = 0;
	int m, n, l;
	cin >> m >> n >> l;
	string s;
	cin >> s;
	for (int i = 0; i < n; i++)
	{
		int st;
		string cs;
		cin >> st >> cs;
		add(cs, st);
		reverse(cs.begin(), cs.end());
		add(cs, st);
	}
	for (int i = 0; i < m; i++)
	{
		int pos = 0;
		for (int j = 0; j < m - i; j++)
		{
			pos = bor[pos][s[i + j] - '0'];
			if (pos == -1)
				break;
			d[i + j + 1] = min((long long)1e17, min(d[i + j + 1], d[i] + borc[pos]));
		}
	}
	if (d[m] >= 1e17)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << d[m] << endl;
	}
}





