#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <fstream>
#include <cassert>

using namespace std;

typedef pair<int, int> ipair;
typedef long long ll;
typedef pair<ll, ll> llpair;

#define ALL(x) begin(x), end(x)

struct Hash {
	const int H1 = 29, H2 = 31, MOD = 1000000007;

	int n;
	vector<llpair> h;
	vector<llpair> pow;

	Hash(const string &s) : n(s.length()), h(n + 1), pow(n + 1) {
		pow[0] = { 1, 1 };
		for (int i = 0; i < n; ++i) {
			h[i + 1].first = (h[i].first * H1 + s[i]) % MOD;
			h[i + 1].second = (h[i].second * H2 + s[i]) % MOD;
			pow[i + 1].first = pow[i].first * H1 % MOD;
			pow[i + 1].second = pow[i].second * H2 % MOD;
		}
	}

	ll mod(ll x) {
		x %= MOD;
		x += MOD;
		x %= MOD;
		return x;
	}

	llpair substr(int l, int r) {
		return{ mod(h[r].first - h[l].first * pow[r - l].first), mod(h[r].second - h[l].second * pow[r - l].second) };
	}
};

int l, n, lsum;
string s;
vector<string> w;
vector<int> c;

const ll LINF = (ll)1e18;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#else
	freopen("twopaths.in", "r", stdin); // двапутя Kappa
	freopen("twopaths.out", "w", stdout);
#endif
	cin.sync_with_stdio(0);
	cin.tie(0);

	cin >> l >> n >> lsum;
	cin >> s;
	Hash hs(s);
	vector<Hash> hw;
	for (int i = 0; i < n; ++i) {
		cin >> c[i] >> w[i];
		hw.emplace_back(w[i]);
	}

	vector<ll> dp(l + 1, LINF);
	for (int i = 0; i < l; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int pl = 1; pl <= (int)w[j].length(); ++pl) {
				if (hw[j].substr(0, pl) == hs.substr(i, i + pl)) {
					dp[i + pl] = min(dp[i + pl], dp[j] + c[j]);
				}
				if (hw[j].substr(w[j].length() - pl, w[j].length()) == hs.substr(i, i + pl)) {
					dp[i + pl] = min(dp[i + pl], dp[j] + c[j]);
				}
			}
		}
	}

	cout << (dp[l] < LINF? dp[l] : -1) << "\n";

	return 0;
}
