
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>

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

using namespace std;

const int MOD     = 1000000007;
const int MAX_LEN = 5002;

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

	int  pows[MAX_LEN] = {};
	char str[MAX_LEN];
	char strs[MAX_LEN][MAX_LEN];

	long long cost[MAX_LEN] = {};

	long long d[MAX_LEN] = {};

	pows[0] = 1;

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

	int len = 0, n = 0, L = 0;
	scanf("%d%d%d", &len, &n, &L);

	scanf("%s", str);

	long long hash[MAX_LEN][MAX_LEN] = {};

	for (int i = 0; i < n; i++)
	{
		scanf("%d%s", &cost[i], strs[i]);
		int curr_len = strlen(strs[i]);

		hash [i][0] = (strs[i][0] - '0');

		for (int j = 1; j < curr_len; j++)
		{
			hash[i][j] = ((hash[i][j - 1] * 2 + strs [i][j] - '0') % MOD);
		}
	}

	for (int i = 0; i < len; i++)
		d[i] = -1;

	for (int i = 0; i < len; i++)
	{
		for (int word = 0; word < n; word++)
		{
			int curr_len = strlen(strs[word]);

			for (int suf = 0; suf <= i; suf++)
			{
				if (suf >= curr_len)
					break;

				if (strs[word][curr_len - 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;
				int curr_len = strlen(strs[word]);

				for (int suf = 0; suf < curr_len; 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;
						}
					}
				}
			}
		}
	}

	printf("%d", d [len - 1]);
	return 0;
}