program kleague;
var a:array[1..25,1..25]of longint;
u,w,d,ma:array[1..25]of longint;
sw,sum,i,j,n,m:longint;
tot:longint;
cheat:array[1..100]of longint;
begin
assign(input,'kleague.in');
assign(output,'kleague.out');
reset(input);
rewrite(output);
read(n);
fillchar(u,sizeof(u),0);
for i:=1 to n do
read(w[i],d[i]);
sum:=0;
for i:=1 to n do
for j:=1 to n do
begin
read(a[i,j]);
inc(u[i],a[i,j]);
sum:=sum+a[i,j];
end;
sum:=sum div 2;
tot:=0;
for i:=1 to n do
begin
ma[i]:=w[i]+u[i];
sw:=0;
for j:=1 to n do
sw:=sw+w[j];
sw:=sw-w[i];
sw:=sw+sum-u[i];
if sw>ma[i]*(n-1) then continue
else
begin
inc(tot);
cheat[tot]:=i;
end;
for j:=1 to n do
begin
if j=i then continue;
if sw div (n-1)<w[i] then
if w[i]>ma[i] then dec(tot);
end;
end;
for i:=1 to tot-1 do
write(cheat[i],' ');
writeln(cheat[tot]);
close(input);
close(output);
end.