#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (600000+10)
#define MAXM (600000+10)
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
int n,m,edge[MAXM],next[MAXM]={0},pre[MAXN]={0},size=0;
void addedge(int u,int v)
{
edge[++size]=v;
next[size]=pre[u];
pre[u]=size;
}
//void addedge2(int u,int v){addedge(u,v),addedge(v,u); }
bool b[MAXN]={0};
int dfs[MAXN],dis[MAXN]={0},s[MAXN]={0},tot=0,numk[MAXN]={0},h[MAXN]={0},kind=0,tim=0;
void tar(int x,int fa)
{
dis[x]=dfs[x]=++tim;b[x]=1;s[++tot]=x;
Forp(x)
{
int v=edge[p];
if (!b[v]) tar(v,x),dfs[x]=min(dfs[x],dfs[v]);
else if (!h[v]) dfs[x]=min(dfs[x],dis[v]);
}
if (dfs[x]==dis[x])
{
++kind;
while (tot)
{
numk[h[s[tot]]=kind]++;
if (s[tot--]==x) break;
}
}
}
int indegree[MAXN]={0};
int main()
{
// freopen("bzoj2438.in","r",stdin);
// freopen(".out","w",stdout);
scanf("%d%d",&n,&m);
For(i,m)
{
int u,v;
scanf("%d%d",&u,&v);
addedge(u,v);
}
For(i,n) if (!b[i]) tar(i,0);
For(x,n)
Forp(x)
{
int v=edge[p];
if (h[x]^h[v]) indegree[h[v]]++;
}
int ans=0,s1=0; //s1表示分量内大小为1的单独块
For(i,kind) if (!indegree[i]) {ans++;if (numk[i]==1) s1=1;}
if (ans>1) ans-=s1;
printf("%.6lf\n",1.000000-(double)ans/n);
// For(i,kind) cout<<numk[i]<<' ';
return 0;
}