var
n,m,p:longint;
f:array[0..50000+10] of longint;
a:array[0..50000+10] of string;
procedure init;
begin
end;
procedure outit;
begin
close(input);
close(output);
halt;
end;
procedure predoing;
var i:longint;
begin
for i:=1 to n do
f[i]:=i;
end;
function find(x:longint):longint;
begin
if f[x]=x then exit(x);
f[x]:=find(f[x]);
exit(f[x]);
end;
procedure insert(x,y:longint);
var rx,ry:longint;
begin
rx:=find(x);
ry:=find(y);
f[rx]:=ry;
end;
procedure readdata;
var
i,j,k:longint;
nx,ny:longint;
t,x,y:string;
begin
readln(n,m,p);
predoing;
for i:=1 to n do
begin
readln(a[i]);
end;
nx:=0;ny:=0;
for j:=1 to m do
begin
readln(t);t:=t+' ';
k:=1;x:='';y:='';
while t[k]<>' ' do
begin
x:=x+t[k];
inc(k);
end;
inc(k);
while t[k]<>' ' do
begin
y:=y+t[k];
inc(k);
end;
for i:=1 to n do
begin
if a[i]=x then
begin
nx:=i;continue;
end;
if a[i]=y then
begin
ny:=i;continue;
end;
if (nx<>0)and(ny<>0) then break;
end;
insert(nx,ny);
nx:=0;ny:=0;
end;
for j:=1 to p do
begin
readln(t);t:=t+' ';
k:=1;x:='';y:='';
while t[k]<>' ' do
begin
x:=x+t[k];
inc(k);
end;
inc(k);
while t[k]<>' ' do
begin
y:=y+t[k];
inc(k);
end;
for i:=1 to n do
begin
if a[i]=x then
begin
nx:=i;continue;
end;
if a[i]=y then
begin
ny:=i;continue;
end;
if (nx<>0)and(ny<>0) then break;
end;
if find(nx)=find(ny) then writeln('safe')
else writeln('cc cry');
nx:=0;ny:=0;
end;
end;
procedure main;
begin
end;
begin
init;
readdata;
main;
outit;
end.
各位帮帮忙!!!