def main():
	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))
	if (n == sum_costs):
		dst = [[100000000] * (m + 1) for i in range(m + 1)]
		for st in range(m):
			for fn in range(st + 1, m + 1):
				leng = fn - st
				for i in arr:
					if (len(i[1]) >= leng):
						if (s[st:fn] == i[1][:leng] or s[st:fn] == i[1][-leng:]):
							dst[st][fn] = min(dst[st][fn], int(i[0]))
		# for i in dst:
		# 	print(i)
		Qst = 0
		Q = [0]
		ans = [-1] * (m + 1)
		ans[0] = 0
		while (Qst < len(Q)):
			proc = Q[Qst];
			Qst += 1
			for i in range(m + 1):
				if (ans[i] == -1 and dst[proc][i] != 100000000):
					ans[i] = ans[proc] + dst[proc][i]
					Q.append(i)
		print(ans[-1], file = outf)
	else:
		print(8, file = outf)

	inf.close()
	outf.close()

main()