var
a,b,c,d,e,ans,ans2:longint;
v:array[1..15]of longint;
f:array[1..15,1..15]of longint;
r:array[1..15]of longint;
p,p1,p2:array[1..15]of boolean;
u:boolean;
ans1,ans3:real;
procedure yy;
var
i,j,mins,minx,miny:longint;
begin
if u=false then exit;
mins:=maxlongint;
for i:=1 to c do
begin
for j:=1 to a do
begin
if (f[r[i],j]<mins)and(f[r[i],j]<>0)and(p2[j]=true) then
begin
mins:=f[r[i],j];
minx:=r[i];
miny:=j;
end;
end;
end;
inc(c);
p2[miny]:=false;
r[c]:=miny;
ans:=ans+f[minx,miny];
if c=b then
begin
ans1:=ans/ans2;
if ans1<ans3 then
begin
p1:=p;
ans3:=ans1;
end;
u:=false;
exit;
end;
yy;
if u=false then
exit;
end;
procedure pd;
var
i:longint;
begin
c:=1;
for i:=1 to a do
if p[i]=true then
begin
e:=i;
break;
end;
fillchar(r,sizeof(r),0);
p2:=p;
p2[e]:=false;
r[c]:=e;
ans:=0;
u:=true;
yy;
end;
procedure ss(i,j:longint);
var
k:longint;
begin
if j=b then
pd;
if i=a+1 then
exit;
if (j<b)and(i<a+1) then
for k:=1 to 2 do
begin
if (k=1) then
begin
p[i]:=true;
ans2:=ans2+v[i];
ss(i+1,j+1);
p[i]:=false;
ans2:=ans2-v[i];
end;
if (k=2) then
ss(i+1,j);
end;
end;
begin
assign(input,'ratio.in');reset(input);
assign(output,'ratio.out');rewrite(output);
readln(a,b);
ans3:=maxlongint;
for c:=1 to a do
read(v[c]);
for c:=1 to a do
begin
for d:=1 to a do
read(f[c,d]);
readln;
end;
fillchar(p,sizeof(p),false);
ss(1,0);
for c:=1 to a do
if p1[c]=true then
write(c,' ');
close(input);
close(output);
end.