def dfs(st, price):
	global arr
	global ans
	global s
	global m
	global n
	if (st == m):
		ans = min(ans, price);
		return
	for i in range(st + 1, m + 1):
		leng = i - st
		for j in arr:
			if(len(j[1]) >= leng):
				if (s[st:i] == j[1][:leng] or s[st:i] == j[1][-leng:]):
					dfs(i, int(j[0]) + price)


inf = open("typing.in", "r")
outf = open("typing.out", "w")

m, n, L = map(int, inf.readline().split())
s = inf.readline()
arr = []
sum_costs = 0
for i in range(n):
	x, y = map(str, inf.readline().split())
	sum_costs += int(x)
	arr.append((x, y))
ans = 1000000000	
dfs(0,0)
if (ans == 1000000000):
	print(-1, file = outf)
else:
	print(ans, file = outf)

inf.close()
outf.close()
