#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];

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;

      	dp[0] = 0;

      	forn(i, m)
      	{
      		for (int len = 1; len < m - i + 1; len++)
      		{
      		        int r = i + len - 1;

      			forn(j, n)
      			{
      				if (sz(t[j]) >= r - i + 1 && (s.substr(i, r - i + 1) == t[j].substr(0, r - i + 1) 
      					|| s.substr(i, r - i + 1) == t[j].substr(sz(t[j]) - (r - i + 1), r - i + 1)))
      					dp[i + len] = min(dp[i + len], dp[i] + c[j]);
      			}
      		}
                                                 
        }

        cout << (dp[m] == INF ? -1 : dp[m]);
	

	return 0;
}