program zht;
var
a,y,c,i:longint;
z:array[1..4] of char;
begin
assign(input,'sjb.in');
assign(output,'sjb.out');
reset(input);
rewrite(output);
readln(a);
for i:=1 to a do
begin
readln(z);
if (z[1]='J') and (z[3]='B') then y:=y+1;
if (z[1]='S') and (z[3]='J') then y:=y+1;
if (z[1]='B') and (z[3]='S') then y:=y+1;
if (z[1]='J') and (z[3]='S') then c:=c+1;
if (z[1]='S') and (z[3]='B') then c:=c+1;
if (z[1]='B') and (z[3]='J') then c:=c+1;
end;
if c>y then write('ck wins');
if y>c then write('ywj wins');
if c=y then write('both ywj and ck win');
close(input);
close(output);
end.