#include <fstream>
#include <unordered_map>
#include <string>
#include <algorithm>

#define MAXN (int)5e5

using namespace std;

unordered_map<long long, pair<int, int>> arr;

string s;
int dp[MAXN];
long long Hash[MAXN];

long long ToH(string s)
{
	long long ans = 1;
	for (auto c : s)
	{
		ans <<= 1;
		if (c == '1')
			ans++;
	}
	return ans;
}

void BuildH()
{
	Hash[0] = s[0] - '0';
	for (int i = 1; i < s.size(); i++)
		Hash[i] = (Hash[i - 1] << 1) + s[i] - '0';
}

long long GetHash(int i, int len)
{
	if (i == 0)
		return (1 << len) + Hash[len - 1];
	else
	{
		long long res = (1 << len) + (Hash[i + len - 1] - (Hash[i - 1] << len));
		return res;
	}
}

int main()
{
	ifstream fin("typing.in");
	ofstream fout("typing.out");
	int m, n, L;
	fin >> m >> n >> L;
	fin >> s;
	BuildH();
	for (int i = 0; i < n; i++)
	{
		int pr;
		string stt;
		fin >> pr >> stt;
		string stt2 = stt;
		reverse(stt2.begin(), stt2.end());
		if (stt.size() > s.size() + 3)
		{
			stt.resize(s.size());
			stt2.resize(s.size());
		}
		
		for (int i = 0; i < stt.size(); i++)
		{
			string su = stt.substr(0, i + 1);
			long long h = ToH(su);
			if (arr[h].first == 0)
			{
				arr[h].first = pr;
				arr[h].second = su.length();
			}
			arr[h].first = min(arr[h].first, pr);
			su = stt2.substr(0, i + 1);
			reverse(su.begin(), su.end());
			h = ToH(su);
			if (arr[h].first == 0)
			{
				arr[h].first = pr;
				arr[h].second = su.length();
			}
			arr[h].first = min(arr[h].first, pr);
		}
	}
	for (int i = 0; i < s.size(); i++)
		for (auto it : arr)
			if (GetHash(i, it.second.second) == it.first)
				if (dp[i + it.second.second] == 0 || dp[i + it.second.second] > dp[i] + it.second.first)
					dp[i + it.second.second] = dp[i] + it.second.first;
	if (dp[s.length()] == 0)
		fout << -1;
	else
		fout << dp[s.length()];
	return 0;
}
