#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define GCC optimize "3"
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <memory.h>
using namespace std;

typedef long long ll;
string s;

const int MAXN = 300002;
const int INF = 1000 * 1000 * 1000 + 2;
const int AN = 800 * 1000;
const int LG = 21;
const int SQ = 951;
string t[MAXN];
char tp[MAXN];
int c[MAXN];
int s2[AN];
ll sp[MAXN][LG];
const ll INFL = (1ll << 60);

struct node
{
	node* e[2];
	int val;
};

node nodes[4 * MAXN];
int nc = 0;

inline node* newnode()
{
	nodes[nc].e[0] = nodes[nc].e[1] = NULL;
	nodes[nc].val = INF;
	return nodes + nc++;
}

struct sufarray
{
	int arr[AN];
	int lcp[AN];
	int sp[AN][LG];
	int id[AN];
};

sufarray pa;
sufarray sa;
int pid[MAXN];
int sid[MAXN];

int p1[AN], p2[AN], cr[AN], p[AN];
int ar[AN];
int ar2[AN];

inline void rd(string& s)
{
	scanf("%s", &tp);
	int ln = strlen(tp);
	s.resize(ln);
	for (int i = 0; i < ln; i++) s[i] = tp[i];
}


inline sufarray buildarray(string& s)
{
	int sl = s.length();
	for (int i = 0; i < sl; i++)
	{
		cr[i] = (int)s[i] + 1;
		ar[i] = i;
	}
	int mx = 300;
	for (int i = 0; (1 << i) < sl; i++)
	{
		for (int j = 0; j < sl; j++)
		{
			p1[j] = cr[j];
			if (j + (1 << i) < sl) p2[j] = cr[j + (1 << i)];
			else p2[j] = 0;
		}
		for (int j = 0; j <= mx; j++) p[j] = 0;
		for (int j = 0; j < sl; j++)
		{
			p[p2[ar[j]]]++;
		}
		for (int j = 1; j < AN; j++) p[j] += p[j - 1];
		for (int j = sl - 1; j >= 0; j--)
		{
			ar2[--p[p2[ar[j]]]] = ar[j];
		}
		for (int j = 0; j <= mx; j++) p[j] = 0;
		for (int j = 0; j < sl; j++)
		{
			p[p1[ar2[j]]]++;
		}
		for (int j = 1; j <= mx; j++) p[j] += p[j - 1];
		for (int j = sl - 1; j >= 0; j--)
		{
			ar[--p[p1[ar2[j]]]] = ar2[j];
		}
		cr[ar[0]] = 1;
		for (int j = 1; j < sl; j++)
		{
			cr[ar[j]] = cr[ar[j - 1]];
			if ((p1[ar[j]] != p1[ar[j - 1]]) || (p2[ar[j]] != p2[ar[j - 1]])) cr[ar[j]]++;
		}
		mx = cr[ar[sl - 1]];
	}
	sufarray ans;
	for (int i = 0; i < sl; i++) ans.arr[i] = ar[i], ans.id[ar[i]] = i;
	int cur = 0;
	for (int i = 0; i < sl; i++)
	{
		cur = max(0, cur - 1);
		if (ans.id[i] + 1 != sl)
		{
			int id2 = ans.arr[ans.id[i] + 1];
			while (s[i + cur] == s[id2 + cur]) cur++;
		}
		ans.lcp[ans.id[i]] = ans.sp[ans.id[i]][0] = cur;
	}
	for (int i = 0; i < sl - 1; i++)
	{
		for (int j = 1; (1 << j) <= (i + 1); j++)
		{
			int st = (i - (1 << j) + 1);
			ans.sp[st][j] = min(ans.sp[st][j - 1], ans.sp[st + (1 << (j - 1))][j - 1]);
		}
	}
	return ans;
}

string prefs;
string sufs;
string tmp;


int bg[MAXN], bc = 0;
ll f[MAXN];

node* root = new node();
node* root2 = new node();

int main()
{
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	s2[1] = 0;
	for (int i = 2; i < AN; i++)
	{
		s2[i] = s2[i - 1];
		if (i >= (1 << (s2[i] + 1))) s2[i]++;
	}
	ios_base::sync_with_stdio(0);
	int m, n, l;
	scanf("%d%d%d", &m, &n, &l);
	rd(s);
	for (int i = 1; i <= m; i++)
	{
		f[i] = INFL;
	}
	prefs = sufs = s;
	reverse(sufs.begin(), sufs.end());
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &c[i]);
		rd(t[i]);
		if (t[i].length() > SQ)
		{
			tmp = t[i];
			pid[bc] = prefs.length();
			bg[bc++] = i;
			prefs += tmp;
			reverse(tmp.begin(), tmp.end());
			sufs += tmp;
		}
		else
		{
			node* cur = root;
			for (int j = t[i].length() - 1; j >= 0; j--)
			{
				int d = t[i][j] - '0';
				if (cur->e[d] == NULL) cur->e[d] = newnode();
				cur = cur->e[d];
				cur->val = min(cur->val, c[i]);
			}
		}
		node* cur = root2;
		for (int j = 0; j < min((int)t[i].length(), SQ); j++)
		{
			int d = t[i][j] - '0';
			if (cur->e[d] == NULL) cur->e[d] = newnode();
			cur = cur->e[d];
			cur->val = min(cur->val, c[i]);
		}
	}
	prefs += '#';
	sufs += '#';
	pa = buildarray(prefs);
	sa = buildarray(sufs);
	for (int i = 0; i < bc; i++)
	{
		sid[i] = sa.id[pid[i]];
		pid[i] = pa.id[pid[i]];
	}
	for (int i = 0; i <= m; i++)
	{
		if (i % SQ == 0)
		{
			for (int j = m - 1; j >= i; j--) f[j] = min(f[j], f[j + 1]);
		}
		if (i != 0)
		{
			node* cur = root;
			for (int j = i - 1; j >= 0; j--)
			{
				int d = s[j] - '0';
				if (cur->e[d] == NULL) break;
				cur = cur->e[d];
				f[i] = min(f[i], f[j] + (ll)cur->val);
			}
			int pd = pa.id[m - i];
			for (int j = 0; j < bc; j++)
			{
				int v = bg[j];
				int lg = pd;
				int rg = sid[j];
				if (lg > rg) swap(lg, rg);
				int d2 = s2[rg - lg];
				int vl = min(sa.sp[lg][d2], sa.sp[rg - (1 << d2)][d2]);
				if (vl == 0) continue;
				lg = i - vl, rg = i;
				d2 = s2[rg - lg];
				f[i] = min(f[i], min(sp[lg][d2], sp[rg - (1 << d2)][d2]) + (ll)c[v]);
			}
		}
		if (i != m)
		{
			int pd = pa.id[i];
			for (int j = 0; j < bc; j++)
			{
				int v = bg[j];
				int lg = pd;
				int rg = pid[j];
				if (lg > rg) swap(lg, rg);
				int d2 = s2[rg - lg];
				int vl = min(pa.sp[lg][d2], pa.sp[rg - (1 << d2)][d2]);
				f[i + vl] = min(f[i + vl], f[i] + (ll)c[v]);
			}
			node* cur = root2;
			for (int j = i; j < m; j++)
			{
				int d = s[j] - '0';
				if (cur->e[d] == NULL) break;
				cur = cur->e[d];
				f[j + 1] = min(f[j + 1], f[i] + (ll)cur->val);
			}
		}
		sp[i][0] = f[i];
		for (int j = 1; (1 << j) <= (i + 1); j++)
		{
			int st = (i - (1 << j) + 1);
			sp[st][j] = min(sp[st][j - 1], sp[st + (1 << (j - 1))][j - 1]);
		}
	}
	if (f[m] != INFL) cout << f[m] << endl;
	else cout << -1 << endl;
	return 0;
}