#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;

const string NAME = "typing";
const int MAXN = 100500;
const ll INF = 1e15;

int n, m, L;
string s;
int c[MAXN];
string t[MAXN];
ll dp[MAXN];
ll tree[4 * MAXN];
ll push[4 * MAXN];


int comsuf(int i, int j)
{
	int ans = 0;

	while (i - ans - 1 >= 0 && sz(t[j]) - 1 - ans >= 0 && s[i - 1 - ans] == t[j][sz(t[j]) - 1 - ans])
		ans++;

	return ans;
}

int compref(int i, int j)
{
	int ans = 0;

	while (i + ans < sz(s) && ans < sz(t[j]) && s[i + ans] == t[j][ans])
		ans++;

	return ans;
}
/*
ll getmin(int v, int tl, int tr, int l, int r)
{
	if (tl == l && tr == r)
	{

	}
}
*/
ll getmin(int l, int r)
{
	ll res = INF;

	for (int i = l; i <= r; i++)
		res = min(res, dp[i]);

	return res;
}

void upd(int l, int r, ll val)
{                     
	for (int i = l; i <= r; i++)
		dp[i] = min(val, dp[i]);
}




int main()
{
#ifndef LOCAL
	freopen((NAME + ".in").c_str(), "rt", stdin);
	freopen((NAME + ".out").c_str(), "wt", stdout);
#endif

	cin >> m >> n >> L;

	cin >> s;

	forn(i, n)
		cin >> c[i] >> t[i];

	forn(i, m + 1)
		dp[i] = INF;

	upd(0, 0, 0);

      	forn(i, m)
      	{       
		forn(j, n)
		{
			upd(i, i, getmin(i - comsuf(i, j), i) + c[j]);
			upd(i, i + compref(i, j), dp[i] + c[j]);
	      	}                                                 
        }
		forn(j, n)
		{

        upd(m, m, getmin(m - comsuf(m, j), m) + c[j]);
}	
        cout << (dp[m] == INF ? -1 : dp[m]);

	return 0;
}