program flux;
const eps=0.00001;
var q,h:text;
bufin,bufout:array[1..1 shl 17] of byte;
sol:array[1..110] of double;
nre:array[1..110] of longint;
g:array[0..110,0..110] of double;
a,b,c,f:array[1..5010] of longint;
l,u,k,n,m,x,y,i,j,auxx:longint;
rez,r,aux:double;
ok:boolean;
v:array of array of longint;
procedure df(nod:longint);
var i:longint;
begin
f[nod]:=1;
for i:=1 to nre[nod] do
if f[v[nod,i]]=0 then df(v[nod,i]);
end;
begin
assign(q,'flux.in'); reset(q);
assign(h,'flux.out'); rewrite(h);
readln(q,n,m);
setlength(v,n+1,1);
for i:=1 to m do
begin
readln(q,a[i],b[i],c[i]);
inc(nre[a[i]]);
inc(nre[b[i]]);
setlength(v[a[i]],nre[a[i]]+1);
setlength(v[b[i]],nre[b[i]]+1);
v[a[i]][nre[a[i]]]:=b[i];
v[b[i]][nre[b[i]]]:=a[i];
end;
df(1);
if f[n]=0 then
begin
r:=0;
writeln(h,r:0:6);
close(q);
close(h);
halt;
end;
for i:=1 to m do
begin
if a[i]<>1 then
begin
g[a[i],a[i]]:=g[a[i],a[i]]+1;
g[a[i],b[i]]:=g[a[i],b[i]]-1;
end;
if b[i]<>1 then
begin
g[b[i],b[i]]:=g[b[i],b[i]]+1;
g[b[i],a[i]]:=g[b[i],a[i]]-1;
end;
end;
g[1,1]:=1;
g[n,n+1]:=1;
i:=1; j:=1;
while (i<=n) and (j<=n) do
begin
ok:=true;
for k:=i to n do
if (g[k,j]>eps) or (g[k,j]<-eps) then
begin
ok:=false;
break;
end;
if ok then
begin
inc(i); inc(j);
continue;
end;
if k<>i then
for l:=1 to n+1 do
begin
aux:=g[i,l];
g[i,l]:=g[k,l];
g[k,l]:=aux;
end;
for l:=j+1 to n+1 do
g[i,l]:=g[i,l]/g[i,j];
g[i,j]:=1;
for u:=i+1 to n do
begin
if u=i then continue;
for l:=j+1 to n+1 do
g[u,l]:=g[u,l]-g[u,j]*g[i,l];
g[u,j]:=0;
end;
inc(i); inc(j);
end;
for i:=n downto 0 do
begin
if (g[i,i]>eps) or (g[i,i]<-eps) then
begin
sol[i]:=g[i,n+1];
for j:=i+1 to n do
sol[i]:=sol[i]-g[i,j]*sol[j];
end;
end;
for i:=1 to m do
begin
if sol[a[i]]<sol[b[i]] then
aux:=a[i]; a[i]:=b[i]; b[i]:=auxx;
if i=1 then rez:=c[i]/(sol[a[i]]-sol[b[i]])
else
if rez>c[i]/(sol[a[i]]-sol[b[i]]) then rez:=c[i]/(sol[a[i]]-sol[b[i]]);
end;
writeln(h,rez:0:6);
close(q); close(h);
end.