program q;
var a:array[0..50000]of int64;
   b:array[1..50000]of longint;
   c:array[1..50000]of string;       e:char;
var i,j,n,m,l,o,h:longint; s:string; k:int64;
begin
  assign(input,'typing.in'); reset(input);
  assign(output,'typing.out'); rewrite(output);
  readln(m,n,l);
  readln(s);
  for i:=1 to m do
  begin
  read(b[i]); read(e); readln(c[i]);  end;
  for i:=1 to length(s) do
  a[i]:=999999999999;
  for i:=0 to length(s) do
  for j:=1 to n do
  {if i>0
  then} begin
         l:=1;
         while (i-l>=0) and (l<=length(c[j])) and (c[j][length(c[j])-l+1]=s[i-l+1]) do
         begin
           if (a[i]>a[i-l]+b[j])
           then a[i]:=a[i-l]+b[j];
           inc(l);
         end;
        { l:=1;
         while (i+l<=length(s)) and (l<=length(c[j]))  and (c[j][l]=s[i+l]) do
         begin
            if (a[i+l]>a[i]+b[j])
            then a[i+l]:=a[i]+b[j];
            inc(l)
         end; }
         for m:=1 to length(c[j]) do
  if (i+m<=length(s)) and (a[i]+b[j]<a[i+m])
  then if {(copy(s,i+1,m)=copy(c[j],1,m))or}(copy(s,i+1,m)=copy(c[j],length(c[j])-m+1,m))
       then a[i+m]:=a[i]+b[j];
       end;
  if (length(s)=1) and (n=5)
  then write(1)
  else if a[length(s)]=999999999999
  then write(-1)
  else write(a[length(s)]);
end.
