30% : n <= 100.
60% : n <= 5000 , m <= 100.
100% : 1 <= n <= 30000 , 1 <= m <= 500. 0 <= p , q 且 p + q <= n.
var
a,b,c,d,e,last,ans,i,j,k,ans1:longint;
v:array[0..30000]of ansistring;
r:array[0..30000]of ansistring;
last1:ansistring;
p:boolean;
procedure ss(l,r:longint);
var
i,j:longint;
mid:ansistring;
begin
i:=l;
j:=r;
mid:=v[(i+j) div 2];
while i<j do
begin
while v[i]<mid do inc(i);
while v[j]>mid do dec(j);
if i<=j then
begin
v[0]:=v[i];
v[i]:=v[j];
v[j]:=v[0];
inc(i);
dec(j);
end;
end;
if j>l then ss(l,j);
if i<r then ss(i,r);
end;
procedure pd;
begin
last:=0;
last1:=v[1];
for e:=1 to a+1 do
begin
if v[e]<>last1 then
begin
if last=d then
begin
inc(ans);
r[ans]:=last1;
end;
last:=1;
last1:=v[e];
end
else
inc(last);
end;
for i:=1 to ans do
begin
P:=true;
for j:=1 to b do
begin
if r[i][j]='N' then r[i][j]:='Y'
else
if r[i][j]='Y' then r[i][j]:='N';
end;
for j:=1 to a do
if r[i]=v[j] then
begin
p:=false;
break;
end;
if p=true then
begin
writeln(r[i]);
halt;
end;
end;
end;
procedure uu(s:ansistring);
var
i:longint;
t:ansistring;
begin
t:='';
for i:=1 to a do
if s=v[i] then
exit;
for j:=1 to b do
begin
if s[j]='N' then t:=t+'Y';
if s[j]='Y' then t:=t+'N';
end;
for i:=1 to a do
if t=v[i] then
exit;
writeln(s);
halt;
end;
procedure hh(s:string);
var
i:longint;
begin
if length(s)=b then
begin
uu(s);
end
else
for i:=1 to 2 do
begin
if i=1 then
hh(s+'N');
if i=2 then
hh(s+'Y');
end;
end;
begin
readln(a,b,c,d);
for e:=1 to a do
readln(v[e]);
ss(1,a);
if (c=0)and(d=0) then
begin
hh('');
end;
if c=0 then
begin
pd;
end;
last:=0;
last1:=v[1];
for e:=1 to a+1 do
begin
if v[e]<>last1 then
begin
if last=c then
begin
inc(ans);
r[ans]:=last1;
end;
last:=1;
last1:=v[e];
end
else
inc(last);
end;
for i:=1 to ans do
begin
ans1:=0;
for j:=1 to a do
begin
p:=true;
for k:=1 to b do
begin
if r[i][k]=v[j][k] then
begin
p:=false;
break;
end;
end;
if p=true then
inc(ans1);
end;
if ans1=d then
begin
writeln(r[i]);
halt;
end;
end;
writeln(-1);
close(input);
end.