
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#pragma comment (linker, "/STACK:100000000")

using namespace std;

const int MOD   = 1000000007;
const int L_MAX = 500002;

int main()
{
	freopen( "typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);


	vector <long long> pows(L_MAX);
	pows[0] = 1;

	for (int i = 1; i < L_MAX; i++)
		pows[i] = (pows[i - 1] * 2) % MOD;

	int len = 0, n = 0, L = 0;
	cin >> len >> n >> L;

	string str;
	cin >> str;

	vector <string>    strs (n);
	vector <long long> cost (n);

	vector < vector <long long> > hash (n);

	for (int i = 0; i < n; i++)
	{
		string str;
		cin >> cost[i] >> str;
		strs[i] = str;

		hash[i].push_back (str[0] - '0');

		for (int j = 1; j < int(str.size()); j++)
		{
			hash[i].push_back ((hash[i][j - 1] * 2 + str[j] - '0') % MOD);
		}
	}

	vector <long long> d(len, -1);

	for (int i = 0; i < len; i++)
	{
		for (int word = 0; word < n; word++)
		{
			for (int suf = 0; suf <= i; suf++)
			{
				if (suf >= strs[word].size())
					break;

				int curr_l = strs[word].size();

				if (strs[word][curr_l - suf - 1] == str[i - suf])
				{
					if (i == suf)
					{
						long long new_ans = cost[word];

						if (d[i] == -1 || new_ans < d[i])
							d[i] = new_ans;
					}
					else
					{
						long long new_ans = d[i - suf - 1] + cost[word];

						if (d[i] == -1 || new_ans < d[i])
							d[i] = new_ans;
					}
				}
				else
					break;
			}

			for (int word = 0; word < n; word++)
			{
				long long curr_hash = 0;

				for (int suf = 0; suf < strs[word].length(); suf++)
				{
					if (suf > i)
						break;

					curr_hash = ((str[i - suf] - '0') * pows[suf] + curr_hash) % MOD;

					if (curr_hash == hash[word][suf])
					{
						if (i == suf)
						{
							long long new_ans = cost[word];

							if (d[i] == -1 || new_ans < d[i])
								d[i] = new_ans;
						}
						else
						{
							long long new_ans = d[i - suf - 1] + cost[word];

							if (d[i] == -1 || new_ans < d[i])
								d[i] = new_ans;
						}
					}
				}
			}
		}
	}

	cout << d.back();
	return 0;
}