program sort;
var n,j,k,max:integer; i,c,l:longint; x:array[1..1000] of longint; y,z:array[1..1000000000]of integer;
s,v:string;
begin
readln(n,c);
readln(s); s:=s+' ';
i:=0;
repeat
i:=i+1;
val(copy(s,1,pos(' ',s)-1),x[i],j);
delete(s,1,pos(' ',s));
until s='';
for i:=1 to n do
y[x[i]]:=y[x[i]]+1;
repeat
j:=0; l:=0; max:=0;
for i:=1 to c do
if y[i]>max then begin max:=y[i]; j:=1; end;
for i:=1 to c do
if y[i]=max then begin l:=l+1; z[l]:=i; k:=y[i]; end;
max:=0;
for i:=1 to l do
if z[l]>max then max:=z[l];
str(max,v);
for i:=1 to k do
s:=s+v+' ';
until j=0;
write(copy(s,1,length(s)-1));
readln
end.
