var
a:array[1..100,1..2] of integer;
temp:array[1..100]of integer;
min,max:integer;
i,j,k,br,n,p:integer;
begin
readln(n,p);
for i:=1 to n do begin
                 for j:=1 to p do read(temp[j]);
                 min:=temp[1];
                 for j:=1 to p do if temp[j]<min then min:=temp[j];
                 max:=temp[1];
                 for j:=1 to p do if temp[j]>max then max:=temp[j];
                 for j:=1 to p do begin
                                  if temp[j]=min then inc(a[j,1]);
                                  if temp[j]=max then inc(a[j,2]);
                                  end;
                 end;
for i:=1 to p do writeln(a[i,1],' ',a[i,2]);
for i:=1 to p do if (a[i,1]>=(n div 2))and(a[i,2]=0) then write(i,' ');
writeln;
end.

