var
c,d,e,n,m:longint;
a:array[1..10000,1..10000]of byte;
f:array[1..10000]of integer;
g:array[1..10000]of byte;
procedure ss(w,l:longint);
var
i:longint;
begin
if (w<>1)and((f[w]=0)or(l<f[w])) then f[w]:=l;
for i:=1 to n do
if (a[w,i]=1)and(g[i]=0) then
begin
g[i]:=1;
ss(i,l+1);
g[i]:=0;
end;
end;
begin
assign(input,'hideseek.in');
assign(output,'hideseek.out');
reset(input);
rewrite(output);
readln(n,m);
for c:=1 to m do
begin
readln(d,e);
a[d,e]:=1;
a[e,d]:=1;
end;
ss(1,0);
e:=1;d:=0;
for c:=2 to n do
begin
if f[c]>f[e] then
begin
e:=c;
d:=0;
end;
if f[c]=f[e] then inc(d);
end;
writeln(e,' ',f[e],' ',d);
close(input);close(output);
end.