var
tot,i,n,c,l:longint;
liang,an,b:array[-1..100000]of boolean;
ans:array[-1..100000]of string;
function ok:boolean;
var
i:longint;
begin
for i:=1 to n do
begin
if (not b[i])and(liang[i]) then exit(false);
if (b[i])and(an[i]) then exit(false);
end;
ok:=true;
end;
procedure go(k:longint);
var
i:longint;
now:array[0..100000]of boolean;
begin
if k>c then
begin
if ok then
begin
inc(tot);
ans[tot]:='';
for i:=1 to n do
if b[i] then ans[tot]:=ans[tot]+'1'
else ans[tot]:=ans[tot]+'0';
end;
exit;
end;
for i:=1 to n do now[i]:=b[i];
for i:=1 to n do
b[i]:=not b[i];
go(k+1);
for i:=1 to n do b[i]:=now[i];
for i:=1 to n do
if i mod 2=1 then b[i]:=not b[i];
go(k+1);
for i:=1 to n do b[i]:=now[i];
for i:=1 to n do
if i mod 2=0 then b[i]:=not b[i];
go(k+1);
for i:=1 to n do b[i]:=now[i];
for i:=1 to n do
if i mod 3=1 then b[i]:=not b[i];
go(k+1);
end;
procedure sort(l,r:longint);
var
i,j:longint;
x,y:string;
begin
i:=l;
j:=r;
x:=ans[(l+r) div 2];
repeat
while ans[i]<x do inc(i);
while x<ans[j] do dec(j);
if i<=j then
begin
y:=ans[i];
ans[i]:=ans[j];
ans[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
begin
assign(input,'partya.in'); reset(input);
assign(output,'partyb.out'); rewrite(output);
readln(n);
readln(c);
read(l);
if l<>-1 then
repeat
liang[l]:=true;
read(l);
until l=-1;
read(l);
if l<>-1 then
repeat
an[l]:=true;
read(l);
until l=-1;
while c>4 do dec(c,2);
for i:=1 to n do b[i]:=true;
go(1);
sort(1,tot);
for i:=1 to tot do
if ans[i]<>ans[i-1] then writeln(ans[i]);
close(input);
close(output);
end.