import java.io.*;
import java.util.*;

public class Pr8Typing {
	public static void main(String[] args) throws IOException {
		new Pr8Typing().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("typing.in"));
		out = new PrintWriter("typing.out");
		solve();
		out.flush();
	}

	final long inf = (long) 1e18;

	HashMap<Long, Integer> pos;

	void add(int num, String s) {
		countHash(s);
		for (int i = 0; i < s.length(); i++) {
			long suf = getHash(i, s.length());
			if (suf != -1 && !(pos.containsKey(suf) && pos.get(suf) <= num)) {
				pos.put(suf, num);
			}
			long pref = getHash(0, i + 1);
			if (pref != -1 && !(pos.containsKey(pref) && pos.get(pref) <= num)) {
				pos.put(pref, num);
			}
		}
	}

	int p = 31;
	long mod = 837723241013387L;
	long[] mainHash;
	long[] pows;
	long[] hash;

	void countHash(String s) {
		hash = new long[s.length() + 1];
		for (int i = 0; i < s.length(); i++) {
			hash[i + 1] = (hash[i] * p) % mod;
			hash[i + 1] += s.charAt(i);
			hash[i + 1] %= mod;
		}
	}

	long getHash(int l, int r) {
		if (r - l >= pows.length) {
			return -1;
		}
		long temp = (hash[r] - (hash[l] * pows[r - l]) % mod) % mod;
		temp = (temp + mod) % mod;
		return temp;
	}

	void countMainHash(String s) {
		mainHash = new long[s.length() + 1];
		pows = new long[s.length() + 1];
		pows[0] = 1;
		for (int i = 0; i < s.length(); i++) {
			mainHash[i + 1] = (mainHash[i] * p) % mod;
			mainHash[i + 1] += s.charAt(i);
			mainHash[i + 1] %= mod;
			pows[i + 1] = (pows[i] * p) % mod;
		}
	}

	long getMainHash(int l, int r) {
		long temp = (mainHash[r] - (mainHash[l] * pows[r - l]) % mod) % mod;
		temp = (temp + mod) % mod;
		return temp;
	}

	void solve() throws IOException {
		int m = nextInt();
		int n = nextInt();
		int L = nextInt();
		String wh = nextToken();
		countMainHash(wh);
		// System.err.println(Arrays.toString(mainHash));
		long[] dp = new long[m + 1];
		Arrays.fill(dp, inf);
		pos = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int num = nextInt();
			String s = nextToken();
			add(num, s);
		}
		dp[0] = 0;
		for (int i = 0; i < m; i++) {
			if (dp[i] == inf)
				continue;
			for (int j = i + 1; j <= m && j <= i + 1000; j++) {
				if (!pos.containsKey(getMainHash(i, j)))
					continue;
				dp[j] = Math.min(dp[j], dp[i] + pos.get(getMainHash(i, j)));
			}
		}
		out.println(dp[m] == inf ? -1 : dp[m]);
	}
}
