var i,j,l,m,n,p,q,t,pre,now,head,tail:longint;
trie:array[0..200000,'A'..'Z'] of longint;
father,next,num,queue:array[0..200000] of longint;
c:array[0..200000] of char;
dg:array[0..200000] of boolean;
dp:array[0..2,0..100000] of double;
win:array[0..100000] of double;
pb:array['A'..'Z',1..2] of double;
s:string;
ch,en,mmm:char;
sum:double;
procedure ins_trie(s:string);
var g,t:longint;
begin
t:=0;
for g:=1 to l do
begin
if trie[t,s[g]]>0 then t:=trie[t,s[g]] else
begin
inc(p);trie[t,s[g]]:=p;
father[p]:=t;
t:=p;c[p]:=s[g];
end;
end;
dg[t]:=true;
num[t]:=i;
end;
begin
fillchar(win,sizeof(win),0);
readln(n,l,m);
en:=chr(ord('A')+m-1);
for i:=1 to m do
begin
readln(p,q);
ch:=chr(i+ord('A')-1);
pb[ch,1]:=p;pb[ch,2]:=q;
end;
p:=0;
for i:=1 to n do
begin
readln(s);
ins_trie(s);
end;
head:=0;tail:=0;
for ch:='A' to en do if trie[0,ch]>0 then
begin
inc(tail);
queue[tail]:=trie[0,ch];
next[queue[tail]]:=0;
end;
while head<tail do
begin
inc(head);
for ch:='A' to en do if trie[queue[head],ch]>0 then
trie:array[0..200000,'A'..'Z'] of longint;
father,next,num,queue:array[0..200000] of longint;
c:array[0..200000] of char;
dg:array[0..200000] of boolean;
dp:array[0..2,0..100000] of double;
win:array[0..100000] of double;
pb:array['A'..'Z',1..2] of double;
s:string;
ch,en,mmm:char;
sum:double;
procedure ins_trie(s:string);
var g,t:longint;
begin
t:=0;
for g:=1 to l do
begin
if trie[t,s[g]]>0 then t:=trie[t,s[g]] else
begin
inc(p);trie[t,s[g]]:=p;
father[p]:=t;
t:=p;c[p]:=s[g];
end;
end;
dg[t]:=true;
num[t]:=i;
end;
begin
fillchar(win,sizeof(win),0);
readln(n,l,m);
en:=chr(ord('A')+m-1);
for i:=1 to m do
begin
readln(p,q);
ch:=chr(i+ord('A')-1);
pb[ch,1]:=p;pb[ch,2]:=q;
end;
p:=0;
for i:=1 to n do
begin
readln(s);
ins_trie(s);
end;
head:=0;tail:=0;
for ch:='A' to en do if trie[0,ch]>0 then
begin
inc(tail);
queue[tail]:=trie[0,ch];
next[queue[tail]]:=0;
end;
while head<tail do
begin
inc(head);
for ch:='A' to en do if trie[queue[head],ch]>0 then