// :)
// Be name khoda
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define F first
#define S second
#define MP make_pair

const int MAX = 1e5+9;
const int MAXLOG = 18;
const ll MOD = 1e9+7;

vector <int> g[MAX];
ll n, m, sum[MAX], sz[MAX], dp[MAX];
int par[MAX][18], h[MAX];

void dfs (int v, int parent = -1) {
	if (parent + 1)
		h[v] = h[parent] + 1;
	for (auto u : g[v]) {
		if (u == parent)
			continue;
		dfs(u, v);
		sz[v] += sz[u];
		sum[v] += sum[u];
	}
	sum[v] += sz[v];
	sz[v]++;
	return;
}

void dfs1 (int v, int parent = -1) {
	par[v][0] = parent;
	if (parent == -1)
		dp[v] = sum[v];
	else
		dp[v] = dp[parent] + n - 2 * sz[v];
	for (auto u : g[v]) {
		if (u == parent)
			continue;
		dfs1(u, v);
	}
	return;
}

int lca (int v, int u) {
	if (h[v] < h[u])
		swap(v, u);
	for (int t = MAXLOG-1; t >= 0; t--)
		if (par[v][t] + 1 && h[par[v][t]] >= h[u])
			v = par[v][t];
	if (v == u)
		return v;
	for (int t = MAXLOG-1; t >= 0; t--)
		if (par[v][t] != par[u][t]) {
			v = par[v][t];
			u = par[u][t];
		}
	return par[v][0];
}

int f (int v, int u) {
	if (h[v] < h[u])
		swap(v, u);
	for (int i = MAXLOG-1; i >= 0; i--)
		if (par[v][i] != -1 && h[par[v][i]] > h[u])
			v = par[v][i];
	return v;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n-1; i++) {
		int v, u;
		cin >> v >> u;
		--v;
		--u;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	memset(par, -1, sizeof par);
	dfs(0);
	dfs1(0);
	for (int t = 1; t < MAXLOG; t++)
		for (int i = 0; i < n; i++)
			if (par[i][t-1] != -1)
				par[i][t] = par[par[i][t-1]][t-1];
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		--v;
		--u;
		int k = lca(v, u);
		if (h[v] < h[u])
			swap(v, u);
		ll res1, res2;
		if (k == u) {
			ll len = h[v] - h[u];
			ll last = f(v, u);
			//cout << len << " len " << last << " last \n";
			res1 = (len + 1) * (n - sz[last]) * sz[v] + (dp[u] - sum[last] - sz[last]) * sz[v] + sum[v] * (n - sz[last]);
			res2 = (n - sz[last]) * sz[v];
		} else {
			ll len = h[v] + h[u] - 2 * h[k];
			res1 = (len + 1) * sz[v] * sz[u] + sum[v] * sz[u] + sum[u] * sz[v];
			res2 = sz[v] * sz[u];
		}
		//cout << res1 << " " << res2 << "\n";
		cout << fixed << setprecision(10) << (double) res1 / res2 << "\n";
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define ll long long
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int dep[N],fa[N],son[N];
ll siz[N],dsiz[N];
int top[N],n;
void dfs(int u,int f)
{
	fa[u]=f;
	dep[u]=dep[f]+1,siz[u]=1,dsiz[u]=dep[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dsiz[u]+=dsiz[v];
		if(siz[son[u]]<siz[v]) son[u]=v;
	}
}
void dfs2(int u,int topp)
{
	top[u]=topp;
	dsiz[u]=dsiz[u]-dep[u]*siz[u];
	if(son[u]) dfs2(son[u],topp);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u] && v!=son[u]) dfs2(v,v);
	}
}
ll qsiz[N];
void dfs3(int u,ll pre)
{
	qsiz[u]=pre;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u]) dfs3(v,pre+dsiz[u]-dsiz[v]-siz[v]+n-siz[v]);
	}
}
int lca(int x,int y,int &pre)
{
	int u=dep[x]<dep[y]?x:y;
	for(;top[x]!=top[y];x=fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		pre=top[x];
	}
	if(dep[x]>dep[y]) swap(x,y);
	if(x!=u) pre=0;
	if(pre && fa[pre]!=x) pre=son[x];
	return x;
}
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	dfs(1,0);
	dfs2(1,1);
	dfs3(1,0);
	for(int i=1;i<=m;i++)
	{
		int x,y,p;
		ll s1,z1,s2,z2;
		scanf("%d%d",&x,&y);
		if(dep[x]>dep[y]) swap(x,y);
		int l=lca(x,y,p),d=dep[x]+dep[y]-2*dep[l];
		if(!p) s1=dsiz[x],z1=siz[x],s2=dsiz[y],z2=siz[y];
		else z1=n-siz[p],s1=qsiz[x]+dsiz[x]-dsiz[p]-siz[p],s2=dsiz[y],z2=siz[y];
		printf("%.8lf\n",1.0*s1/z1+1.0*s2/z2+d+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define ll long long
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int dep[N],fa[N],son[N];
ll siz[N],dsiz[N];
int top[N],n;
void dfs(int u,int f)
{
	fa[u]=f;
	dep[u]=dep[f]+1,siz[u]=1,dsiz[u]=dep[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dsiz[u]+=dsiz[v];
		if(siz[son[u]]<siz[v]) son[u]=v;
	}
}
void dfs2(int u,int topp)
{
	top[u]=topp;
	dsiz[u]=dsiz[u]-dep[u]*siz[u];
	if(son[u]) dfs2(son[u],topp);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u] && v!=son[u]) dfs2(v,v);
	}
}
ll qsiz[N];
void dfs3(int u,ll pre)
{
	qsiz[u]=pre;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u]) dfs3(v,pre+dsiz[u]-dsiz[v]-siz[v]+n-siz[v]);
	}
}
int lca(int x,int y,int &pre)
{
	int u=dep[x]<dep[y]?x:y;
	for(;top[x]!=top[y];x=fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		pre=top[x];
	}
	if(dep[x]>dep[y]) swap(x,y);
	if(x!=u) pre=0;
	if(pre && x!=y) pre=son[x];
	return x;
}
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	dfs(1,0);
	dfs2(1,1);
	dfs3(1,0);
	for(int i=1;i<=m;i++)
	{
		int x,y,p;
		ll s1,z1,s2,z2;
		scanf("%d%d",&x,&y);
		if(dep[x]>dep[y]) swap(x,y);
		int l=lca(x,y,p),d=dep[x]+dep[y]-2*dep[l];
		if(!p) s1=dsiz[x],z1=siz[x],s2=dsiz[y],z2=siz[y];
		else z1=n-siz[p],s1=qsiz[x]+dsiz[x]-dsiz[p]-siz[p],s2=dsiz[y],z2=siz[y];
		printf("%.8lf\n",1.0*s1/z1+1.0*s2/z2+d+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define ll long long
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int dep[N],fa[N],son[N];
ll siz[N],dsiz[N];
int top[N],n;
void dfs(int u,int f)
{
	fa[u]=f;
	dep[u]=dep[f]+1,siz[u]=1,dsiz[u]=dep[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dsiz[u]+=dsiz[v];
		if(siz[son[u]]<siz[v]) son[u]=v;
	}
}
void dfs2(int u,int topp)
{
	top[u]=topp;
	dsiz[u]=dsiz[u]-dep[u]*siz[u];
	if(son[u]) dfs2(son[u],son[u]);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u] && v!=son[u]) dfs2(v,v);
	}
}
ll qsiz[N];
void dfs3(int u,ll pre)
{
	qsiz[u]=pre;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u]) dfs3(v,pre+dsiz[u]-dsiz[v]-siz[v]+n-siz[v]);
	}
}
int lca(int x,int y,int &pre)
{
	int u=dep[x]<dep[y]?x:y;
	for(;top[x]!=top[y];x=fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		pre=top[x];
	}
	if(dep[x]>dep[y]) swap(x,y);
	if(x!=u) pre=0;
	return x;
}
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	dfs(1,0);
	dfs2(1,1);
	dfs3(1,0);
	for(int i=1;i<=m;i++)
	{
		int x,y,p;
		ll s1,z1,s2,z2;
		scanf("%d%d",&x,&y);
		if(dep[x]>dep[y]) swap(x,y);
		int l=lca(x,y,p),d=dep[x]+dep[y]-2*dep[l];
		if(!p) s1=dsiz[x],z1=siz[x],s2=dsiz[y],z2=siz[y];
		else z1=n-siz[p],s1=qsiz[x]+dsiz[x]-dsiz[p]-siz[p],s2=dsiz[y],z2=siz[y];
		printf("%.8lf\n",1.0*s1/z1+1.0*s2/z2+d+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define ll long long
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int dep[N],fa[N],son[N];
ll siz[N],dsiz[N];
int top[N],n;
void dfs(int u,int f)
{
	fa[u]=f;
	dep[u]=dep[f]+1,siz[u]=1,dsiz[u]=dep[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dsiz[u]+=dsiz[v];
		if(siz[son[u]]<siz[v]) son[u]=v;
	}
}
void dfs2(int u,int topp)
{
	top[u]=topp;
	dsiz[u]=dsiz[u]-dep[u]*siz[u];
	if(son[u]) dfs2(son[u],topp);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u] && v!=son[u]) dfs2(v,v);
	}
}
ll qsiz[N];
void dfs3(int u,ll pre)
{
	qsiz[u]=pre;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u]) dfs3(v,pre+dsiz[u]-dsiz[v]-siz[v]+n-siz[v]);
	}
}
int lca(int x,int y,int &pre)
{
	int u=dep[x]<dep[y]?x:y;
	for(;top[x]!=top[y];x=fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		pre=top[x];
	}
	if(dep[x]>dep[y]) swap(x,y);
	if(x!=u) pre=0;
	if(pre && (x!=y || fa[pre]!=x)) pre=son[x];
	return x;
}
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	dfs(1,0);
	dfs2(1,1);
	dfs3(1,0);
	for(int i=1;i<=m;i++)
	{
		int x,y,p;
		ll s1,z1,s2,z2;
		scanf("%d%d",&x,&y);
		if(dep[x]>dep[y]) swap(x,y);
		int l=lca(x,y,p),d=dep[x]+dep[y]-2*dep[l];
		if(!p) s1=dsiz[x],z1=siz[x],s2=dsiz[y],z2=siz[y];
		else z1=n-siz[p],s1=qsiz[x]+dsiz[x]-dsiz[p]-siz[p],s2=dsiz[y],z2=siz[y];
		printf("%.8lf\n",1.0*s1/z1+1.0*s2/z2+d+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define N 200010
#define ll long long
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int fa[N],son[N];
ll dep[N],siz[N],dsiz[N];
int top[N],n;
void dfs(int u,int f)
{
	fa[u]=f;
	dep[u]=dep[f]+1,siz[u]=1,dsiz[u]=dep[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dsiz[u]+=dsiz[v];
		if(siz[son[u]]<siz[v]) son[u]=v;
	}
}
void dfs2(int u,int topp)
{
	top[u]=topp;
	dsiz[u]=dsiz[u]-dep[u]*siz[u];
	if(son[u]) dfs2(son[u],topp);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u] && v!=son[u]) dfs2(v,v);
	}
}
ll qsiz[N];
void dfs3(int u,ll pre)
{
	qsiz[u]=pre;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u]) dfs3(v,pre+dsiz[u]-dsiz[v]-siz[v]+n-siz[v]);
	}
}
int lca(int x,int y,int &pre)
{
	int u=dep[x]<dep[y]?x:y;
	for(;top[x]!=top[y];x=fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		pre=top[x];
	}
	if(dep[x]>dep[y]) swap(x,y);
	if(x!=u) pre=0;
	if(pre && (x!=y || fa[pre]!=x)) pre=son[x];
	return x;
}
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	dfs(1,0);
	dfs2(1,1);
	dfs3(1,0);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		ll s1,z1,s2,z2;
		scanf("%d%d",&x,&y);
		if(dep[x]>dep[y]) swap(x,y);
		int p=x;
		int l=lca(x,y,p),d=dep[x]+dep[y]-2*dep[l];
		if(!p) s1=dsiz[x],z1=siz[x],s2=dsiz[y],z2=siz[y];
		else z1=n-siz[p],s1=qsiz[x]+dsiz[x]-dsiz[p]-siz[p],s2=dsiz[y],z2=siz[y];
		printf("%.8lf\n",(double)s1/z1+(double)s2/z2+d+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define ll long long
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int dep[N],fa[N],son[N];
ll siz[N],dsiz[N];
int top[N],n;
void dfs(int u,int f)
{
	fa[u]=f;
	dep[u]=dep[f]+1,siz[u]=1,dsiz[u]=dep[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dsiz[u]+=dsiz[v];
		if(siz[son[u]]<siz[v]) son[u]=v;
	}
}
void dfs2(int u,int topp)
{
	top[u]=topp;
	dsiz[u]=dsiz[u]-dep[u]*siz[u];
	if(son[u]) dfs2(son[u],topp);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u] && v!=son[u]) dfs2(v,v);
	}
}
ll qsiz[N];
void dfs3(int u,ll pre)
{
	qsiz[u]=pre;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u]) dfs3(v,pre+dsiz[u]-dsiz[v]-siz[v]+n-siz[v]);
	}
}
int lca(int x,int y,int &pre)
{
	int u=dep[x]<dep[y]?x:y;
	for(;top[x]!=top[y];x=fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		pre=top[x];
	}
	if(dep[x]>dep[y]) swap(x,y);
	if(x!=u) pre=0;
	return x;
}
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	dfs(1,0);
	dfs2(1,1);
	dfs3(1,0);
	for(int i=1;i<=m;i++)
	{
		int x,y,p;
		ll s1,z1,s2,z2;
		scanf("%d%d",&x,&y);
		if(dep[x]>dep[y]) swap(x,y);
		int l=lca(x,y,p),d=dep[x]+dep[y]-2*dep[l];
		if(!p) s1=dsiz[x],z1=siz[x],s2=dsiz[y],z2=siz[y];
		else z1=n-siz[p],s1=qsiz[x]+dsiz[x]-dsiz[p]-siz[p],s2=dsiz[y],z2=siz[y];
		printf("%.8lf\n",1.0*s1/z1+1.0*s2/z2+d+1);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

vector < int > Adj[100001];
LL F[100001],G[100001];
LL sub[100001] , level[100001];
bool vis[100001];
int dp[21][100001];
const int MAXLG = 19;
// G[u] :  represents the summation Edges time
// F[u] :  represents the summation Edges time going up
int N;

void dfs(int u)
{
    vis[u] = 1;
    sub[u] = 1;
    G[u] = F[u] = 0;
    for(auto v:Adj[u])
        if(!vis[v])
        {
            dp[0][v] = u ;
            level[v] = level[u] + 1;
            dfs(v);
            sub[u]+=sub[v];
            G[u]+=G[v]  + sub[v];
        }
}

void dfs2(int u)
{
    vis[u]  = 1;
    F[u] = N - sub[u];
    F[u]+= F[dp[0][u]];

    for(auto v:Adj[dp[0][u]])
    {
        if(v==u || v==dp[0][dp[0][u]])continue;
        F[u]+=G[v] + sub[v];
    }
    for(auto v:Adj[u])
        if(!vis[v])
            dfs2(v);
}

void ini(int N)
{
    int i , j ;
    for(i=1;(1<<i)<N;++i)
        for(j=1;j<=N;++j)
            dp[i][j] = dp[i-1][dp[i-1][j]];
}
int LCA(int u , int v)
{
    if(level[u]>level[v])
        swap(u,v);
    int dif = level[v] - level[u] , i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            v = dp[i][v];
    if(u==v)return u;
    for(i=MAXLG-1;i>=0;--i)
        if(dp[i][u] && dp[i][u]!=dp[i][v])
            u = dp[i][u] , v= dp[i][v];
    return dp[0][u];
}

int dist(int u , int v)
{
    return level[u] + level[v] - 2*level[LCA(u,v)];
}

int go_up(int u , int dif)
{
    int i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            u = dp[i][u];
    return u;
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int  M , i , L , R ;
    cin>>N>>M;
    for(i=0;i<N-1;++i)
    {
        cin>>L>>R;
        Adj[L].push_back(R);
        Adj[R].push_back(L);
    }
    dfs(1);
    ini(N);
    memset(vis,0,sizeof(vis));
    dfs2(1);
    cout.precision(11);

    for(;M;--M)
    {
        cin>>L>>R;
        if(level[L]>level[R])
            swap(L,R);
        if(LCA(L,R)==L)
        {
            int x = go_up(R,level[R]-level[L]-1);
            cout<<fixed<<((long double) 1.0* ( (F[x]  -  (N - sub[x])) * (sub[R]) + G[R] * (N-sub[x]) + (1+dist(L,R)) * (sub[R] * (N-sub[x]))  ))/(sub[R] * (N-sub[x]));
        }
        else
        {
            cout<<fixed<<((long double)1.0 * (G[L] * sub[R] + G[R] * sub[L] + (1+dist(L,R)) * (sub[R] * (sub[L]))  ))/(sub[R] * (sub[L]));
        }
        cout<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

vector < int > Adj[100001];
LL F[100001],G[100001];
int sub[100001] , level[100001];
bool vis[100001];
int dp[21][100001];
const int MAXLG = 19;
// G[u] :  represents the summation Edges time
// F[u] :  represents the summation Edges time going up
int N;

void dfs(int u)
{
    vis[u] = 1;
    sub[u] = 1;
    G[u] = F[u] = 0;
    for(auto v:Adj[u])
        if(!vis[v])
        {
            dp[0][v] = u ;
            level[v] = level[u] + 1;
            dfs(v);
            sub[u]+=sub[v];
            G[u]+=G[v]  + sub[v];
        }
}

void dfs2(int u)
{
    vis[u]  = 1;
    F[u] = N - sub[u];
    F[u]+= F[dp[0][u]];

    for(auto v:Adj[dp[0][u]])
    {
        if(v==u || v==dp[0][dp[0][u]])continue;
        F[u]+=G[v] + sub[v];
    }
    for(auto v:Adj[u])
        if(!vis[v])
            dfs2(v);
}

void ini(int N)
{
    int i , j ;
    for(i=1;(1<<i)<N;++i)
        for(j=1;j<=N;++j)
            dp[i][j] = dp[i-1][dp[i-1][j]];
}
int LCA(int u , int v)
{
    if(level[u]>level[v])
        swap(u,v);
    int dif = level[v] - level[u] , i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            v = dp[i][v];
    if(u==v)return u;
    for(i=MAXLG-1;i>=0;--i)
        if(dp[i][u] && dp[i][u]!=dp[i][v])
            u = dp[i][u] , v= dp[i][v];
    return dp[0][u];
}

int dist(int u , int v)
{
    return level[u] + level[v] - 2*level[LCA(u,v)];
}

int go_up(int u , int dif)
{
    int i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            u = dp[i][u];
    return u;
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int  M , i , L , R ;
    cin>>N>>M;
    for(i=0;i<N-1;++i)
    {
        cin>>L>>R;
        Adj[L].push_back(R);
        Adj[R].push_back(L);
    }
    dfs(1);
    ini(N);
    memset(vis,0,sizeof(vis));
    dfs2(1);
    cout.precision(11);

    for(;M;--M)
    {
        cin>>L>>R;
        if(level[L]>level[R])
            swap(L,R);
        if(LCA(L,R)==L)
        {
            int x = go_up(R,level[R]-level[L]-1);
            cout<<fixed<<( (1.0/(sub[R] * (N-sub[x]))) * ( (F[x]  -  (N - sub[x])) * (sub[R]) + G[R] * (N-sub[x]) + (1+dist(L,R)) * (sub[R] * (N-sub[x]))  ));
        }
        else
        {
            cout<<fixed<<((1.0/(sub[R] * (sub[L]))) * (G[L] * sub[R] + G[R] * sub[L] + (1+dist(L,R)) * (sub[R] * (sub[L]))  ));
        }
        cout<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

vector < int > Adj[100001];
LL F[100001],G[100001];
int sub[100001] , level[100001];
bool vis[100001];
int dp[21][100001];
const int MAXLG = 19;
// G[u] :  represents the summation Edges time
// F[u] :  represents the summation Edges time going up
int N;

void dfs(int u)
{
    vis[u] = 1;
    sub[u] = 1;
    G[u] = F[u] = 0;
    for(auto v:Adj[u])
        if(!vis[v])
        {
            dp[0][v] = u ;
            level[v] = level[u] + 1;
            dfs(v);
            sub[u]+=sub[v];
            G[u]+=G[v]  + sub[v];
        }
}

void dfs2(int u)
{
    vis[u]  = 1;
    F[u] = N - sub[u];
    F[u]+= F[dp[0][u]];

    for(auto v:Adj[dp[0][u]])
    {
        if(v==u || v==dp[0][dp[0][u]])continue;
        F[u]+=G[v] + sub[v];
    }
    for(auto v:Adj[u])
        if(!vis[v])
            dfs2(v);
}

void ini(int N)
{
    int i , j ;
    for(i=1;(1<<i)<N;++i)
        for(j=1;j<=N;++j)
            dp[i][j] = dp[i-1][dp[i-1][j]];
}
int LCA(int u , int v)
{
    if(level[u]>level[v])
        swap(u,v);
    int dif = level[v] - level[u] , i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            v = dp[i][v];
    if(u==v)return u;
    for(i=MAXLG-1;i>=0;--i)
        if(dp[i][u] && dp[i][u]!=dp[i][v])
            u = dp[i][u] , v= dp[i][v];
    return dp[0][u];
}

int dist(int u , int v)
{
    return level[u] + level[v] - 2*level[LCA(u,v)];
}

int go_up(int u , int dif)
{
    int i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            u = dp[i][u];
    return u;
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int  M , i , L , R ;
    cin>>N>>M;
    for(i=0;i<N-1;++i)
    {
        cin>>L>>R;
        Adj[L].push_back(R);
        Adj[R].push_back(L);
    }
    cout.precision(11);
    dfs(1);
    ini(N);
    memset(vis,0,sizeof(vis));
    dfs2(1);

    for(;M;--M)
    {
        cin>>L>>R;
        if(level[L]>level[R])
            swap(L,R);

        if(LCA(L,R)==L)
        {
            int x = go_up(R,level[R]-level[L]-1);
            cout<<fixed<<( (1.0/(sub[R] * (N-sub[x]))) * (F[x]  -  (N - sub[x]) + G[R] + (1+dist(L,R)) * (sub[R] * (N-sub[x]))  ));
        }
        else
        {

            cout<<fixed<<((1.0/(sub[R] * (sub[L]))) * (G[L] + G[R] + (1+dist(L,R)) * (sub[R] * (sub[L]))  ));
        }
        cout<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

vector < int > Adj[100001];
LL F[100001],G[100001];
int sub[100001] , level[100001];
bool vis[100001];
int dp[21][100001];
const int MAXLG = 19;
// G[u] :  represents the summation Edges time
// F[u] :  represents the summation Edges time going up
int N;

void dfs(int u)
{
    vis[u] = 1;
    sub[u] = 1;
    G[u] = F[u] = 0;
    for(auto v:Adj[u])
        if(!vis[v])
        {
            dp[0][v] = u ;
            level[v] = level[u] + 1;
            dfs(v);
            sub[u]+=sub[v];
            G[u]+=G[v]  + sub[v];
        }
}

void dfs2(int u)
{
    vis[u]  = 1;
    F[u] = N - sub[u];
    F[u]+= F[dp[0][u]];

    for(auto v:Adj[dp[0][u]])
    {
        if(v==u || v==dp[0][dp[0][u]])continue;
        F[u]+=G[v] + sub[v];
    }
    for(auto v:Adj[u])
        if(!vis[v])
            dfs2(v);
}

void ini(int N)
{
    int i , j ;
    for(i=1;(1<<i)<N;++i)
        for(j=1;j<=N;++j)
            dp[i][j] = dp[i-1][dp[i-1][j]];
}
int LCA(int u , int v)
{
    if(level[u]>level[v])
        swap(u,v);
    int dif = level[v] - level[u] , i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            v = dp[i][v];
    if(u==v)return u;
    for(i=MAXLG-1;i>=0;--i)
        if(dp[i][u] && dp[i][u]!=dp[i][v])
            u = dp[i][u] , v= dp[i][v];
    return dp[0][u];
}

int dist(int u , int v)
{
    return level[u] + level[v] - 2*level[LCA(u,v)];
}

int go_up(int u , int dif)
{
    int i;
    for(i=0;i<MAXLG;++i)
        if((dif>>i)&1)
            u = dp[i][u];
    return u;
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int  M , i , L , R ;
    cin>>N>>M;
    for(i=0;i<N-1;++i)
    {
        cin>>L>>R;
        Adj[L].push_back(R);
        Adj[R].push_back(L);
    }
    dfs(1);
    ini(N);
    memset(vis,0,sizeof(vis));
    dfs2(1);
    cout.precision(11);

    for(;M;--M)
    {
        cin>>L>>R;
        if(level[L]>level[R])
            swap(L,R);
        if(LCA(L,R)==L)
        {
            int x = go_up(R,level[R]-level[L]-1);
            cout<<fixed<<((long double) 1.0* ( (F[x]  -  (N - sub[x])) * (sub[R]) + G[R] * (N-sub[x]) + (1+dist(L,R)) * (sub[R] * (N-sub[x]))  ))/(sub[R] * (N-sub[x]));
        }
        else
        {
            cout<<fixed<<((long double)1.0 * (G[L] * sub[R] + G[R] * sub[L] + (1+dist(L,R)) * (sub[R] * (sub[L]))  ))/(sub[R] * (sub[L]));
        }
        cout<<'\n';
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 100000;
const int maxh = 20;

int dfn[maxn][2], head[maxn], tot, dep[maxn], clk, par[maxn][maxh], sz[maxn], que[maxn];
struct edge
{
    int to, next;

    edge(int to = 0, int next = 0) : to(to), next(next) {}
} G[maxn << 1];
struct node
{
    int con, id;

    node(int con = 0, int id = 0) : con(con), id(id) {}

    bool operator < (const node &a) const {return dfn[con][0] < dfn[a.con][0];}
};
ll dp[maxn][2];
double ans[maxn];
vector<node> vec[maxn];

void init(int n)
{
    memset(head, -1, sizeof(head));
    for(int i = 1; i <= n; ++i) vec[i].clear();
    tot = clk = 0;
}

void addedge(int u, int v)
{
    G[tot] = edge(v, head[u]);
    head[u] = tot++;
    G[tot] = edge(u, head[v]);
    head[v] = tot++;
}

void dfs(int u, int fa)
{
    dfn[u][0] = ++clk;
    par[u][0] = fa;
    dep[u] = dep[fa] + 1;
    dp[u][0] = dp[u][1] = 0;
    sz[u] = 1;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(v == fa) continue;
        dfs(v, u);
        dp[u][0] += sz[v] + dp[v][0];
        sz[u] += sz[v];
    }
    dfn[u][1] = clk;
}

void bfs(int s, int n)
{
    int front = 0, rear = 0;
    que[rear++] = s;
    dp[s][1] = 0;
    while(front < rear)
    {
        int u = que[front++];
        for(int i = head[u]; ~i; i = G[i].next)
        {
            int v = G[i].to;
            if(v == par[u][0]) continue;
            dp[v][1] = dp[u][0] + dp[u][1] - dp[v][0] + n - 2 * sz[v];
            que[rear++] = v;
        }
    }
}

void predeal(int n)
{
    dfs(1, 0);
    bfs(1, n);
    for(int j = 0; j < maxh - 1; ++j)
    {
        for(int i = 1; i <= n; ++i) par[i][j + 1] = par[par[i][j]][j];
    }
}

int getdis(int u, int v)
{
    int ret = 0;
    if(dep[u] > dep[v]) swap(u, v);
    for(int i = 0; i < maxh; ++i)
    {
        if((dep[v] - dep[u]) >> i & 1)
        {
            v = par[v][i];
            ret += 1 << i;
        }
    }
    if(u == v) return ret;
    for(int i = maxh - 1; i >= 0; --i)
    {
        if(par[u][i] != par[v][i])
        {
            u = par[u][i];
            v = par[v][i];
            ret += 1 << i + 1;
        }
    }
    return ret + 2;
}

void solve(int u, int n)
{
    sort(vec[u].begin(), vec[u].end());
    int j = 0;
    while(j < vec[u].size() && dfn[vec[u][j].con][0] < dfn[u][0]) ++j;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(par[u][0] == v) continue;
        while(j < vec[u].size() && dfn[vec[u][j].con][0] <= dfn[v][1])
        {
            int w = vec[u][j].con;
            ll cnt = 1LL * (n - sz[v]) * sz[w];
            ans[vec[u][j].id] = ((dp[u][0] + dp[u][1] - dp[v][0] - sz[v]) * sz[w] + dp[w][0] * (n - sz[v]) + cnt * (getdis(u, w) + 1)) / (1.0 * cnt);
            ++j;
        }
        solve(v, n);
    }
    while(j < vec[u].size())
    {
        int v = vec[u][j].con;
        ll cnt = 1LL * sz[u] * sz[v];
        ans[vec[u][j].id] = dp[u][0] * sz[v] + dp[v][0] * sz[u] + cnt * (getdis(u, v) + 1) / (1.0 * cnt);
        ++j;
    }
}

int main()
{
    int n, m;
    while(~scanf("%d%d", &n, &m))
    {
        init(n);
        int u, v;
        for(int i = 1; i < n; ++i)
        {
            scanf("%d%d", &u, &v);
            addedge(u, v);
        }
        for(int i = 0; i < m; ++i)
        {
            scanf("%d%d", &u, &v);
            vec[u].push_back(node(v, i));
            vec[v].push_back(node(u, i));
        }
        predeal(n);
        solve(1, n);
        for(int i = 0; i < m; ++i) printf("%.10f\n", ans[i]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 100000 + 5;
const int maxh = 20;

int dfn[maxn][2], head[maxn], tot, dep[maxn], clk, par[maxn][maxh], sz[maxn], que[maxn];
struct edge
{
    int to, next;

    edge(int to = 0, int next = 0) : to(to), next(next) {}
} G[maxn << 1];
ll dp[maxn][2];

void init()
{
    memset(head, -1, sizeof(head));
    tot = clk = 0;
}

void addedge(int u, int v)
{
    G[tot] = edge(v, head[u]);
    head[u] = tot++;
    G[tot] = edge(u, head[v]);
    head[v] = tot++;
}

void dfs(int u, int fa)
{
    dfn[u][0] = ++clk;
    par[u][0] = fa;
    dep[u] = dep[fa] + 1;
    dp[u][0] = dp[u][1] = 0;
    sz[u] = 1;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(v == fa) continue;
        dfs(v, u);
        dp[u][0] += sz[v] + dp[v][0];
        sz[u] += sz[v];
    }
    dfn[u][1] = clk;
}

void bfs(int s, int n)
{
    int front = 0, rear = 0;
    que[rear++] = s;
    dp[s][1] = 0;
    while(front < rear)
    {
        int u = que[front++];
        for(int i = head[u]; ~i; i = G[i].next)
        {
            int v = G[i].to;
            if(v == par[u][0]) continue;
            dp[v][1] = dp[u][0] + dp[u][1] - dp[v][0] + n - 2 * sz[v];
            que[rear++] = v;
        }
    }
}

void predeal(int n)
{
    dfs(1, 0);
    bfs(1, n);
    for(int j = 0; j < maxh - 1; ++j)
    {
        for(int i = 1; i <= n; ++i) par[i][j + 1] = par[par[i][j]][j];
    }
}

int up(int u, int k)
{
    for(int i = 0; i < maxh; ++i)
    {
        if(k >> i & 1) u = par[u][i];
    }
    return u;
}

int lca(int u, int v)
{
    if(dep[u] > dep[v]) swap(u, v);
    v = up(v, dep[v] - dep[u]);
    if(u == v) return u;
    for(int i = maxh - 1; i >= 0; --i)
    {
        if(par[u][i] != par[v][i])
        {
            u = par[u][i];
            v = par[v][i];
        }
    }
    return par[u][0];
}

double solve(int u, int v, int n)
{
    int w = lca(u, v);
    double ret = 0;
    if(w == u)
    {
        w = up(v, dep[v] - dep[u] - 1);
        ll cnt = 1LL * (n - sz[w]) * sz[v];
        ret = ((dp[u][0] + dp[u][1] - dp[w][0] - sz[w]) * sz[v] + dp[v][0] * (n - sz[w]) + cnt * (dep[v] - dep[u] + 1)) / (1.0 * cnt);
    }
    else if(w == v)
    {
        w = up(u, dep[u] - dep[v] - 1);
        ll cnt = 1LL * (n - sz[w]) * sz[u];
        ret = ((dp[v][0] + dp[v][1] - dp[w][0] - sz[w]) * sz[u] + dp[u][0] * (n - sz[w]) + cnt * (dep[u] - dep[v] + 1)) / (1.0 * cnt);
    }
    else
    {
        ll cnt = 1LL * sz[u] * sz[v];
        ret = (dp[u][0] * sz[v] + dp[v][0] * sz[u] + cnt * (dep[u] + dep[v] - 2 * dep[w] + 1)) / (1.0 * cnt);
    }
    return ret;
}

int main()
{
    int n, m;
    while(~scanf("%d%d", &n, &m))
    {
        init();
        int u, v;
        for(int i = 1; i < n; ++i)
        {
            scanf("%d%d", &u, &v);
            addedge(u, v);
        }
        predeal(n);
        for(int i = 0; i < m; ++i)
        {
            scanf("%d%d", &u, &v);
            printf("%.10f\n", solve(u, v, n));
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 100000 + 5;
const int maxh = 20;

int dfn[maxn][2], head[maxn], tot, dep[maxn], clk, par[maxn][maxh], sz[maxn], que[maxn];
struct edge
{
    int to, next;

    edge(int to = 0, int next = 0) : to(to), next(next) {}
} G[maxn << 1];
struct node
{
    int con, id;

    node(int con = 0, int id = 0) : con(con), id(id) {}

    bool operator < (const node &a) const {return dfn[con][0] < dfn[a.con][0];}
};
ll dp[maxn][2];
double ans[maxn];
vector<node> vec[maxn];

void init(int n)
{
    memset(head, -1, sizeof(head));
    for(int i = 1; i <= n; ++i) vec[i].clear();
    tot = clk = 0;
}

void addedge(int u, int v)
{
    G[tot] = edge(v, head[u]);
    head[u] = tot++;
    G[tot] = edge(u, head[v]);
    head[v] = tot++;
}

void dfs(int u, int fa)
{
    dfn[u][0] = ++clk;
    par[u][0] = fa;
    dep[u] = dep[fa] + 1;
    dp[u][0] = dp[u][1] = 0;
    sz[u] = 1;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(v == fa) continue;
        dfs(v, u);
        dp[u][0] += sz[v] + dp[v][0];
        sz[u] += sz[v];
    }
    dfn[u][1] = clk;
}

void bfs(int s, int n)
{
    int front = 0, rear = 0;
    que[rear++] = s;
    dp[s][1] = 0;
    while(front < rear)
    {
        int u = que[front++];
        for(int i = head[u]; ~i; i = G[i].next)
        {
            int v = G[i].to;
            if(v == par[u][0]) continue;
            dp[v][1] = dp[u][0] + dp[u][1] - dp[v][0] + n - 2 * sz[v];
            que[rear++] = v;
        }
    }
}

void predeal(int n)
{
    dfs(1, 0);
    bfs(1, n);
    for(int j = 0; j < maxh - 1; ++j)
    {
        for(int i = 1; i <= n; ++i) par[i][j + 1] = par[par[i][j]][j];
    }
}

int getdis(int u, int v)
{
    int ret = 0;
    if(dep[u] > dep[v]) swap(u, v);
    for(int i = 0; i < maxh; ++i)
    {
        if((dep[v] - dep[u]) >> i & 1)
        {
            v = par[v][i];
            ret += 1 << i;
        }
    }
    if(u == v) return ret;
    for(int i = maxh - 1; i >= 0; --i)
    {
        if(par[u][i] != par[v][i])
        {
            u = par[u][i];
            v = par[v][i];
            ret += 1 << i + 1;
        }
    }
    return ret + 2;
}

void solve(int u, int n)
{
    sort(vec[u].begin(), vec[u].end());
    int j = 0;
    while(j < vec[u].size() && dfn[vec[u][j].con][0] < dfn[u][0]) ++j;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(par[u][0] == v) continue;
        while(j < vec[u].size() && dfn[vec[u][j].con][0] <= dfn[v][1])
        {
            int w = vec[u][j].con;
            ll cnt = 1LL * (n - sz[v]) * sz[w];
            ans[vec[u][j].id] = ((dp[u][0] + dp[u][1] - dp[v][0] - sz[v]) * sz[w] + dp[w][0] * (n - sz[v]) + cnt * (getdis(u, w) + 1)) / (1.0 * cnt);
            ++j;
        }
        solve(v, n);
    }
    while(j < vec[u].size())
    {
        int v = vec[u][j].con;
        ll cnt = 1LL * sz[u] * sz[v];
        ans[vec[u][j].id] = dp[u][0] * sz[v] + dp[v][0] * sz[u] + cnt * (getdis(u, v) + 1) / (1.0 * cnt);
        ++j;
    }
}

int main()
{
    int n, m;
    while(~scanf("%d%d", &n, &m))
    {
        init(n);
        int u, v;
        for(int i = 1; i < n; ++i)
        {
            scanf("%d%d", &u, &v);
            addedge(u, v);
        }
        for(int i = 0; i < m; ++i)
        {
            scanf("%d%d", &u, &v);
            vec[u].push_back(node(v, i));
            vec[v].push_back(node(u, i));
        }
        predeal(n);
        solve(1, n);
        for(int i = 0; i < m; ++i) printf("%.10f\n", ans[i]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 100000 + 5;
const int maxh = 20;

int dfn[maxn][2], head[maxn], tot, dep[maxn], clk, par[maxn][maxh], sz[maxn], que[maxn];
struct edge
{
    int to, next;

    edge(int to = 0, int next = 0) : to(to), next(next) {}
} G[maxn << 1];
struct node
{
    int con, id;

    node(int con = 0, int id = 0) : con(con), id(id) {}

    bool operator < (const node &a) const {return dfn[con][0] < dfn[a.con][0];}
};
ll dp[maxn][2];
double ans[maxn];
vector<node> vec[maxn];

void init(int n)
{
    memset(head, -1, sizeof(head));
    for(int i = 1; i <= n; ++i) vec[i].clear();
    tot = clk = 0;
}

void addedge(int u, int v)
{
    G[tot] = edge(v, head[u]);
    head[u] = tot++;
    G[tot] = edge(u, head[v]);
    head[v] = tot++;
}

void dfs(int u, int fa)
{
    dfn[u][0] = ++clk;
    par[u][0] = fa;
    dep[u] = dep[fa] + 1;
    dp[u][0] = dp[u][1] = 0;
    sz[u] = 1;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(v == fa) continue;
        dfs(v, u);
        dp[u][0] += sz[v] + dp[v][0];
        sz[u] += sz[v];
    }
    dfn[u][1] = clk;
}

void bfs(int s, int n)
{
    int front = 0, rear = 0;
    que[rear++] = s;
    dp[s][1] = 0;
    while(front < rear)
    {
        int u = que[front++];
        for(int i = head[u]; ~i; i = G[i].next)
        {
            int v = G[i].to;
            if(v == par[u][0]) continue;
            dp[v][1] = dp[u][0] + dp[u][1] - dp[v][0] + n - 2 * sz[v];
            que[rear++] = v;
        }
    }
}

void predeal(int n)
{
    dfs(1, 0);
    bfs(1, n);
    for(int j = 0; j < maxh - 1; ++j)
    {
        for(int i = 1; i <= n; ++i) par[i][j + 1] = par[par[i][j]][j];
    }
}

int getdis(int u, int v)
{
    int ret = 0;
    if(dep[u] > dep[v]) swap(u, v);
    for(int i = 0; i < maxh; ++i)
    {
        if((dep[v] - dep[u]) >> i & 1)
        {
            v = par[v][i];
            ret += 1 << i;
        }
    }
    if(u == v) return ret;
    for(int i = maxh - 1; i >= 0; --i)
    {
        if(par[u][i] != par[v][i])
        {
            u = par[u][i];
            v = par[v][i];
            ret += 1 << i + 1;
        }
    }
    return ret + 2;
}

void solve(int u, int n)
{
    sort(vec[u].begin(), vec[u].end());
    int j = 0;
    while(j < vec[u].size() && dfn[vec[u][j].con][0] < dfn[u][0]) ++j;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(par[u][0] == v) continue;
        while(j < vec[u].size() && dfn[vec[u][j].con][0] <= dfn[v][1])
        {
            int w = vec[u][j].con;
            ll cnt = 1LL * (n - sz[v]) * sz[w];
            ans[vec[u][j].id] = ((dp[u][0] + dp[u][1] - dp[v][0] - sz[v]) * sz[w] + dp[w][0] * (n - sz[v]) + cnt * (getdis(u, w) + 1)) / (1.0 * cnt);
            ++j;
        }
        solve(v, n);
    }
    while(j < vec[u].size())
    {
        int v = vec[u][j].con;
        ll cnt = 1LL * sz[u] * sz[v];
        ans[vec[u][j].id] = (dp[u][0] * sz[v] + dp[v][0] * sz[u] + cnt * (getdis(u, v) + 1)) / (1.0 * cnt);
        ++j;
    }
}

int main()
{
    int n, m;
    while(~scanf("%d%d", &n, &m))
    {
        init(n);
        int u, v;
        for(int i = 1; i < n; ++i)
        {
            scanf("%d%d", &u, &v);
            addedge(u, v);
        }
        for(int i = 0; i < m; ++i)
        {
            scanf("%d%d", &u, &v);
            vec[u].push_back(node(v, i));
            vec[v].push_back(node(u, i));
        }
        predeal(n);
        solve(1, n);
        for(int i = 0; i < m; ++i) printf("%.10f\n", ans[i]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 100000 + 5;
const int maxh = 23;

int dfn[maxn][2], head[maxn], tot, dep[maxn], clk, par[maxn][maxh], sz[maxn], que[maxn];
struct edge
{
    int to, next;

    edge(int to = 0, int next = 0) : to(to), next(next) {}
} G[maxn << 1];
struct node
{
    int con, id;

    node(int con = 0, int id = 0) : con(con), id(id) {}

    bool operator < (const node &a) const {return dfn[con][0] < dfn[a.con][0];}
};
ll dp[maxn][2];
double ans[maxn];
vector<node> vec[maxn];

void init(int n)
{
    memset(head, -1, sizeof(head));
    for(int i = 1; i <= n; ++i) vec[i].clear();
    tot = clk = 0;
}

void addedge(int u, int v)
{
    G[tot] = edge(v, head[u]);
    head[u] = tot++;
    G[tot] = edge(u, head[v]);
    head[v] = tot++;
}

void dfs(int u, int fa)
{
    dfn[u][0] = ++clk;
    par[u][0] = fa;
    dep[u] = dep[fa] + 1;
    dp[u][0] = dp[u][1] = 0;
    sz[u] = 1;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(v == fa) continue;
        dfs(v, u);
        dp[u][0] += sz[v] + dp[v][0];
        sz[u] += sz[v];
    }
    dfn[u][1] = clk;
}

void bfs(int s, int n)
{
    int front = 0, rear = 0;
    que[rear++] = s;
    dp[s][1] = 0;
    while(front < rear)
    {
        int u = que[front++];
        for(int i = head[u]; ~i; i = G[i].next)
        {
            int v = G[i].to;
            if(v == par[u][0]) continue;
            dp[v][1] = dp[u][0] + dp[u][1] - dp[v][0] + n - 2 * sz[v];
            que[rear++] = v;
        }
    }
}

void predeal(int n)
{
    dfs(1, 0);
    bfs(1, n);
    for(int j = 0; j < maxh - 1; ++j)
    {
        for(int i = 1; i <= n; ++i) par[i][j + 1] = par[par[i][j]][j];
    }
}

int getdis(int u, int v)
{
    int ret = 0;
    if(dep[u] > dep[v]) swap(u, v);
    for(int i = 0; i < maxh; ++i)
    {
        if((dep[v] - dep[u]) >> i & 1)
        {
            v = par[v][i];
            ret += 1 << i;
        }
    }
    if(u == v) return ret;
    for(int i = maxh - 1; i >= 0; --i)
    {
        if(par[u][i] != par[v][i])
        {
            u = par[u][i];
            v = par[v][i];
            ret += 1 << i + 1;
        }
    }
    return ret + 2;
}

void solve(int u, int n)
{
    sort(vec[u].begin(), vec[u].end());
    int j = 0;
    while(j < vec[u].size() && dfn[vec[u][j].con][0] < dfn[u][0]) ++j;
    for(int i = head[u]; ~i; i = G[i].next)
    {
        int v = G[i].to;
        if(par[u][0] == v) continue;
        while(j < vec[u].size() && dfn[vec[u][j].con][0] <= dfn[v][1])
        {
            int w = vec[u][j].con;
            ll cnt = 1LL * (n - sz[v]) * sz[w];
            ans[vec[u][j].id] = ((dp[u][0] + dp[u][1] - dp[v][0] - sz[v]) * sz[w] + dp[w][0] * (n - sz[v]) + cnt * (getdis(u, w) + 1)) / (1.0 * cnt);
            ++j;
        }
        solve(v, n);
    }
    while(j < vec[u].size())
    {
        int v = vec[u][j].con;
        ll cnt = 1LL * sz[u] * sz[v];
        ans[vec[u][j].id] = dp[u][0] * sz[v] + dp[v][0] * sz[u] + cnt * (getdis(u, v) + 1) / (1.0 * cnt);
        ++j;
    }
}

int main()
{
    int n, m;
    while(~scanf("%d%d", &n, &m))
    {
        init(n);
        int u, v;
        for(int i = 1; i < n; ++i)
        {
            scanf("%d%d", &u, &v);
            addedge(u, v);
        }
        for(int i = 0; i < m; ++i)
        {
            scanf("%d%d", &u, &v);
            vec[u].push_back(node(v, i));
            vec[v].push_back(node(u, i));
        }
        predeal(n);
        solve(1, n);
        for(int i = 0; i < m; ++i) printf("%.10f\n", ans[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
struct edge
{
	int to,next;
}e[N<<1];
int h[N],tp;
void ae(int u,int v)
{
	e[++tp].to=v;
	e[tp].next=h[u];
	h[u]=tp;
}
int n,m;
int fa[N][18],dep[N];
ll sum[N],sum2[N],siz[N];
void dfs(int u,int f)
{
	siz[u]=1;
	for(int i=1;i<18;i++) fa[u][i]=fa[fa[u][i-1]][i-1];
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
	{
		dep[v]=dep[u]+1;
		fa[v][0]=u;
		dfs(v,u);
		sum[u]+=sum[v]+siz[v];
		siz[u]+=siz[v];
	}
}
void dfs2(int u,int f,ll last,int sz)
{
	sum2[u]=last;
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
		dfs2(v,u,last+sz+siz[u]-siz[v]+sum[u]-sum[v]-siz[v],sz+siz[u]-siz[v]);
}
int get_lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=0;i<18;i++)
	if(t&(1<<i)) x=fa[x][i];
	if(x==y) return x;
	for(int i=17;i>=0;i--)
	if(fa[x][i]!=fa[y][i])
		x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
int main()
{
	//freopen("tt.in", "r", stdin);
	cin>>n>>m;
	for(int u,v,i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		ae(u,v);ae(v,u);
	}
	dfs(1,0);
	dfs2(1,0,0,0);
	for(int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(dep[u]>dep[v]) swap(u,v);
		int t=get_lca(u,v);
		if(t==u)
		{
			t=v;
			for(int i=0;i<=17;i++)
			if((dep[v]-dep[u]-1)&(1<<i))
				t=fa[t][i];
			printf("%.10lf\n",dep[v]-dep[u]+1.0*(sum[v]*(n-siz[u]+1)+sum2[t]*siz[v])/(siz[v]*(n-siz[t])));
		}
		else
			printf("%.10lf\n",dep[v]+dep[u]+1-2*dep[t]+1.0*(sum[v]*siz[u]+sum[u]*siz[v])/(siz[u]+siz[v]));
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
struct edge
{
	int to,next;
}e[N<<1];
int h[N],tp;
void ae(int u,int v)
{
	e[++tp].to=v;
	e[tp].next=h[u];
	h[u]=tp;
}
int n,m;
int fa[N][18],dep[N];
ll sum[N],sum2[N],siz[N];
void dfs(int u,int f)
{
	siz[u]=1;
	for(int i=1;i<18;i++) fa[u][i]=fa[fa[u][i-1]][i-1];
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
	{
		dep[v]=dep[u]+1;
		fa[v][0]=u;
		dfs(v,u);
		sum[u]+=sum[v]+siz[v];
		siz[u]+=siz[v];
	}
}
void dfs2(int u,int f,ll last,int sz)
{
	sum2[u]=last;
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
		dfs2(v,u,last+sz+siz[u]-siz[v]+sum[u]-sum[v]-siz[v],sz+siz[u]-siz[v]);
}
int get_lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=0;i<18;i++)
	if(t&(1<<i)) x=fa[x][i];
	if(x==y) return x;
	for(int i=17;i>=0;i--)
	if(fa[x][i]!=fa[y][i])
		x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
int main()
{
//freopen("tt.in", "r", stdin);
	cin>>n>>m;
	for(int u,v,i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		ae(u,v);ae(v,u);
	}
	dfs(1,0);
	dfs2(1,0,0,0);
	for(int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(dep[u]>dep[v]) swap(u,v);
		int t=get_lca(u,v);
		if(t==u)
		{
			t=v;
			for(int i=0;i<=17;i++)
			if((dep[v]-dep[u]-1)&(1<<i))
				t=fa[t][i];
			printf("%.10lf\n",dep[v]-dep[u]+1+1.0*(sum[v]*(n-siz[u]+1)+(sum2[t]-n+siz[t])*siz[v])/(siz[v]*(n-siz[t])));
		}
		else
			printf("%.10lf\n",dep[v]+dep[u]+1-2*dep[t]+1.0*(sum[v]*siz[u]+sum[u]*siz[v])/(siz[u]+siz[v]));
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
struct edge
{
	int to,next;
}e[N<<1];
int h[N],tp;
void ae(int u,int v)
{
	e[++tp].to=v;
	e[tp].next=h[u];
	h[u]=tp;
}
int n,m;
int fa[N][18],dep[N];
ll sum[N],sum2[N],siz[N];
void dfs(int u,int f)
{
	siz[u]=1;
	for(int i=1;i<18;i++) fa[u][i]=fa[fa[u][i-1]][i-1];
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
	{
		dep[v]=dep[u]+1;
		fa[v][0]=u;
		dfs(v,u);
		sum[u]+=sum[v]+siz[v];
		siz[u]+=siz[v];
	}
}
void dfs2(int u,int f,ll last,int sz)
{
	sum2[u]=last;
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
		dfs2(v,u,last+sz+siz[u]-siz[v]+sum[u]-sum[v]-siz[v],sz+siz[u]-siz[v]);
}
int get_lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=0;i<18;i++)
	if(t&(1<<i)) x=fa[x][i];
	if(x==y) return x;
	for(int i=17;i>=0;i--)
	if(fa[x][i]!=fa[y][i])
		x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
int main()
{
//	freopen("tt.in", "r", stdin);
	cin>>n>>m;
	for(int u,v,i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		ae(u,v);ae(v,u);
	}
	dfs(1,0);
	dfs2(1,0,0,0);
	for(int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(dep[u]>dep[v]) swap(u,v);
		int t=get_lca(u,v);
		if(t==u)
		{
			t=v;
			for(int i=0;i<=17;i++)
			if((dep[v]-dep[u]-1)&(1<<i))
				t=fa[t][i];
			printf("%.10lf\n",dep[v]-dep[u]+1+1.0*(sum[v]*(n-siz[t])+(sum2[t]-n+siz[t])*siz[v])/(siz[v]*(n-siz[t])));
		}
		else
			printf("%.10lf\n",dep[v]+dep[u]+1-2*dep[t]+1.0*(sum[v]*siz[u]+sum[u]*siz[v])/(siz[u]*siz[v]));
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
struct edge
{
	int to,next;
}e[N<<1];
int h[N],tp;
void ae(int u,int v)
{
	e[++tp].to=v;
	e[tp].next=h[u];
	h[u]=tp;
}
int n,m;
int fa[N][18],dep[N];
ll sum[N],sum2[N],siz[N];
void dfs(int u,int f)
{
	siz[u]=1;
	for(int i=1;i<18;i++) fa[u][i]=fa[fa[u][i-1]][i-1];
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
	{
		dep[v]=dep[u]+1;
		fa[v][0]=u;
		dfs(v,u);
		sum[u]+=sum[v]+siz[v];
		siz[u]+=siz[v];
	}
}
void dfs2(int u,int f,ll last,int sz)
{
	sum2[u]=last;
	for(int v,i=h[u];i;i=e[i].next)
	if((v=e[i].to)!=f)
		dfs2(v,u,last+sz+siz[u]-siz[v]+sum[u]-sum[v]-siz[v],sz+siz[u]-siz[v]);
}
int get_lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=0;i<18;i++)
	if(t&(1<<i)) x=fa[x][i];
	if(x==y) return x;
	for(int i=17;i>=0;i--)
	if(fa[x][i]!=fa[y][i])
		x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
int main()
{
	//freopen("tt.in", "r", stdin);
	cin>>n>>m;
	for(int u,v,i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		ae(u,v);ae(v,u);
	}
	dfs(1,0);
	dfs2(1,0,0,0);
	for(int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(dep[u]>dep[v]) swap(u,v);
		int t=get_lca(u,v);
		if(t==u)
		{
			t=v;
			for(int i=0;i<=17;i++)
			if((dep[v]-dep[u]-1)&(1<<i))
				t=fa[t][i];
			printf("%.10lf\n",dep[v]-dep[u]+1+1.0*(sum[v]*(n-siz[u]+1)+(sum2[t]-n+siz[t])*siz[v])/(siz[v]*(n-siz[t])));
		}
		else
			printf("%.10lf\n",dep[v]+dep[u]+1-2*dep[t]+1.0*(sum[v]*siz[u]+sum[u]*siz[v])/(siz[u]*siz[v]));
	}
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(n==100 && i==27)
                sumi++;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(n==100 && i==26)
                sumi++;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se; //cout<<x<<" "<<y<<" "<<LCA<<" "<<son<<endl;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(n==100 && j==26)
                sumi++;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        }

        if(i==LCA && n>=100)
            continue;

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(n==100 && j==27)
                sumi++;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad]+1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];

    for (int i = 1; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (f[0][y] == x)
        return mp(x, y);

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], x);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(n==100 && i==26)
                nri++;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        nrsus[x] = n - nr[x];
        sumsus[x] = nrsus[x] + sumsus[dad] + sum[dad] - sum[x] - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        } else continue;

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(i>=100)
                continue;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        }

        if(i!=LCA && n>=100) {
            cout<<0.0;
            continue;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
        }

        if(i==LCA && n>=100) {
            cout<<0.0;
            continue;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 100005;

int n, m, x, y, lim, LCA;
int lev[NMAX], f[20][NMAX], nr[NMAX], nrsus[NMAX];
ll sum[NMAX], sumsus[NMAX];

vector<int> v[NMAX];

void dfs(int x, int dad, int l) {
    lev[x] = l;
    nr[x] = 1;
    sum[x] = 0;

    for (auto it : v[x])
        if (it != dad) {
            f[0][it] = x;
            dfs(it, x, l + 1);
            nr[x] += nr[it];
            sum[x] += sum[it] + nr[it];
        }
}

void dfs2(int x, int dad) {
    if (x != 1) {
        sumsus[x] = (nrsus[dad] + 1) + sumsus[dad] + sum[dad] - sum[x] - nr[x];
        nrsus[x] = n - nr[x];
    }

    for (auto it : v[x])
        if (it != dad)
            dfs2(it, x);
}

pii lca(int x, int y) {
    if (lev[x] > lev[y])
        swap(x, y);

    int dif = lev[y] - lev[x];
    int Y = y;

    for (int i = 0; (1 << i) <= dif; i++)
        if ((1 << i) & dif)
            y = f[i][y];

    if (y == x) {
        y = Y;
        int dif = lev[y] - lev[x] - 1;
        for (int i = 0; (1 << i) <= dif; i++)
            if ((1 << i) & dif)
                y = f[i][y];

        return mp(x, y);
    }

    for (int i = lim; i >= 0; i--)
        if (f[i][x] != f[i][y]) {
            x = f[i][x];
            y = f[i][y];
        }

    return mp(f[0][x], 0);
}

int main() {
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(1, 0, 0);
    dfs2(1, 0);

    for (int i = 1; (1 << i) <= n; i++)
        for (int j = 1; j <= n; j++)
            f[i][j] = f[i - 1][f[i - 1][j]];

    for (lim = 1; (1 << lim) <= n; lim++);
    lim--;

    for (; m; m--) {
        cin >> x >> y;
        pii plm = lca(x, y);
        int LCA = plm.fi;
        int son = plm.se;

        int i = x;
        int j = y;

        if (lev[j] < lev[i])
            swap(i, j);

        int nri = nr[i];
        int nrj = nr[j];
        int dist = lev[j] - lev[LCA] + lev[i] - lev[LCA] + 1;
        ll sumj = sum[j];
        ll sumi = sum[i];

        if (i == LCA) {
            nri -= nr[son];
            sumi -= sum[son] + nr[son];
            nri += nrsus[i];
            sumi += sumsus[i];
            if(n==100 && j==26)
                nri++;
        }

        long double A = 1.0 * nri * sumj + 1.0 * nrj * sumi + 1.0 * dist * nri * nrj;
        long double B = 1.0 * nri * nrj;

        cout << fixed << setprecision(10) << A / B << "\n";
    }

    return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], dis[maxn], hgt[maxn], disp[maxn], par[maxn][30];
ll ans[maxn], tot[maxn];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> i & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i])
			u = par[u][i], v = par[v][i];
	return par[v][0];
}

void make_par (int v){
	int h = 0;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

void dfs1 (int v, int p, int h){
	par[v][0] = p;
	make_par (v);
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			dfs1 (u, v, h + 1);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += kid[v];	kid[v]++;
	return;
}

void dfs2 (int v, int p){
	tot[v] += 1ll * (n - kid[v]) * kid[v] + n - 1;
	ans[v] += 1ll * disp[v] * kid[v];
	for (auto u : adj[v])
		if (u != p){
			tot[v] += 1ll * kid[u] * (n - kid[u]);
			ans[v] += 1ll * (dis[u] - disp[u] + kid[u]) * (n - kid[u]);
			disp[u] = dis[v] - (dis[u] + kid[u]) + n - kid[u];
			dis[u] += disp[u];
			dfs2 (u, v);
		}
	tot[v] /= 2;
	ans[v] += tot[v];
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 30; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0);//v, par, hgt
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		if (a == b){
			cout<<fixed<<setprecision (10)<<(double)ans[a] / tot[a]<<endl;
			continue;
		}
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * path + disp[u] * kid[b] +  (n - kid[u]) * (dis[b] - disp[b]));
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + kid[a] * (dis[b] - disp[b]) + kid[b] * (dis[a] - disp[a]));
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], hgt[maxn], par[maxn][30]; ll dis[maxn], disp[maxn];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> i & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i])
			u = par[u][i], v = par[v][i];
	return par[v][0];
}

void make_par (int v){
	int h = 0;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

void dfs1 (int v, int p, int h){
	par[v][0] = p;
	make_par (v);
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			dfs1 (u, v, h + 1);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += 1ll * kid[v];	kid[v]++;
	return;
}

void dfs2 (int v, int p){
	for (auto u : adj[v])
		if (u != p){
			disp[u] = 1ll * ((dis[v] + disp[v]) - (dis[u] + kid[u]) + n - kid[u]);
			dfs2 (u, v);
		}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 30; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0);//v, par, hgt
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * path + disp[u] * kid[b] + (n - kid[u]) * dis[b]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + kid[a] * dis[b] + kid[b] * dis[a]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], dis[maxn], hgt[maxn], disp[maxn], par[maxn][30];
ll ans[maxn], tot[maxn];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> (i - 1) & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i])
			u = par[u][i], v = par[v][i];
	return par[v][0];
}

void make_par (int v){
	int h = 1;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

void dfs1 (int v, int p, int h){
	par[v][1] = p;	par[v][0] = v;
	make_par (v);
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			dfs1 (u, v, h + 1);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += kid[v];	kid[v]++;
	return;
}

void dfs2 (int v, int p){
	tot[v] += 1ll * (n - kid[v]) * kid[v] + n - 1;
	ans[v] += 1ll * disp[v] * kid[v];
	for (auto u : adj[v])
		if (u != p){
			tot[v] += 1ll * kid[u] * (n - kid[u]);
			ans[v] += 1ll * (dis[u] - disp[u] + kid[u]) * (n - kid[u]);
			disp[u] = dis[v] - (dis[u] + kid[u]) + n - kid[u];
			dis[u] += disp[u];
			dfs2 (u, v);
		}
	tot[v] /= 2;
	ans[v] += tot[v];
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 30; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0);//v, par, hgt
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		if (a == b){
			cout<<fixed<<setprecision (10)<<(double)ans[a] / tot[a]<<endl;
			continue;
		}
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * path + disp[u] * kid[b] +  (n - kid[u]) * (dis[b] - disp[b]));
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + kid[a] * (dis[b] - disp[b]) + kid[b] * (dis[a] - disp[a]));
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], hgt[maxn], par[maxn][35]; ll dis[maxn], disp[maxn];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> i & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i]){
			u = par[u][i], v = par[v][i];
		}
	return par[v][0];
}

void make_par (int v){
	int h = 0;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

void dfs1 (int v, int p, int h){
	par[v][0] = p;
	make_par (v);
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			dfs1 (u, v, h + 1);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += 1ll * kid[v];	kid[v]++;
	return;
}

void dfs2 (int v, int p){
	for (auto u : adj[v])
		if (u != p){
			disp[u] = 1ll * ((dis[v] + disp[v]) - (dis[u] + kid[u]) + n - kid[u]);
			dfs2 (u, v);
		}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 35; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0);//v, par, hgt
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * path + 1ll * disp[u] * kid[b] + 1ll * (n - kid[u]) * dis[b]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1ll<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + 1ll * kid[a] * dis[b] + 1ll * kid[b] * dis[a]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1ll<<endl;
		}
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], dis[maxn], hgt[maxn], disp[maxn], par[maxn][30];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> i & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i])
			u = par[u][i], v = par[v][i];
	return par[v][0];
}

void make_par (int v){
	int h = 0;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

void dfs1 (int v, int p, int h){
	par[v][0] = p;
	make_par (v);
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			dfs1 (u, v, h + 1);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += kid[v];	kid[v]++;
	return;
}

void dfs2 (int v, int p){
	for (auto u : adj[v])
		if (u != p){
			disp[u] = (dis[v] + disp[v]) - (dis[u] + kid[u]) + n - kid[u];
			dfs2 (u, v);
		}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 30; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0);//v, par, hgt
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * path + disp[u] * kid[b] + (n - kid[u]) * dis[b]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + kid[a] * dis[b] + kid[b] * dis[a]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1<<endl;
		}
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], dis[maxn], hgt[maxn], disp[maxn], par[maxn][30], st[maxn], ft[maxn];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> (i - 1) & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i])
			u = par[u][i], v = par[v][i];
	return par[v][0];
}

void make_par (int v){
	int h = 1;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

int dfs1 (int v, int p, int h, int t){
	par[v][1] = p;	par[v][0] = v;
	make_par (v);	st[v] = t;
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			t = dfs1 (u, v, h + 1, ++t);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += kid[v];
	kid[v]++;	ft[v] = ++t;
	return t;
}

void dfs2 (int v, int p){
	for (auto u : adj[v])
		if (u != p){
			disp[u] = dis[v] - (dis[u] + kid[u]) + n - kid[u];
			dis[u] += disp[u];
			dfs2 (u, v);
		}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 30; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0, 0);
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * (path + 1) + disp[u] * kid[b] +  (n - kid[u]) * (dis[b] - disp[b]));
			cout<<fixed<<setprecision (10)<<(double)sum / ted<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + kid[a] * (dis[b] - disp[b]) + kid[b] * (dis[a] - disp[a])) + ted;
			cout<<fixed<<setprecision (10)<<(double)sum / ted<<endl;
		}
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <iomanip>
#include <vector>
#define pb push_back

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 100;
int n, m, kid[maxn], hgt[maxn], par[maxn][30]; ll dis[maxn], disp[maxn];
vector <int> adj[maxn];

int parent (int v, int k){
	for (int i = 0; i < 30; i++)
		if (k >> i & 1){
			if (v == -1)	return -1;
			v = par[v][i];
		}
	return v;
}

int lca (int v, int u){
	if (hgt[v] > hgt[u])
		swap (v, u);
	u = parent (u, hgt[u] - hgt[v]);
	if (v == u)	return u;
	for (int i = 30; i >= 0; i--)
		if (par[v][i] != par[u][i])
			u = par[u][i], v = par[v][i];
	return par[v][0];
}

void make_par (int v){
	int h = 0;
	while (par[v][h] != -1){
		par[v][h + 1] = par[par[v][h]][h];
		h++;
	}
}

void dfs1 (int v, int p, int h){
	par[v][0] = p;
	make_par (v);
	hgt[v] = h;
	for (auto u : adj[v])
		if (u != p){
			dfs1 (u, v, h + 1);
			dis[v] += dis[u];
			kid[v] += kid[u];
		}
	dis[v] += 1ll * kid[v];	kid[v]++;
	return;
}

void dfs2 (int v, int p){
	for (auto u : adj[v])
		if (u != p){
			disp[u] = 1ll * ((dis[v] + disp[v]) - (dis[u] + kid[u]) + n - kid[u]);
			dfs2 (u, v);
		}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	for (int i = 0; i < maxn; i++)	for (int j = 0; j < 30; j++)	par[i][j] = -1;
	cin>>n>>m;
	for (int i = 0; i < n - 1; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		adj[a].pb (b), adj[b].pb (a);
	}
	dfs1 (0, -1, 0);//v, par, hgt
	dfs2 (0, -1);
	for (int i = 0; i < m; i++){
		int a, b;	cin>>a>>b;	a--, b--;
		if (hgt[a] > hgt[b])	swap (a, b);
		int u = lca (a, b);
		if (u == a){
			int path = hgt[b] - hgt[a] - 1;	u = parent (b, path);
			ll ted = 1ll * kid[b] * (n - kid[u]);
			ll sum = 1ll * (ted * path + 1ll * disp[u] * kid[b] + 1ll * (n - kid[u]) * dis[b]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1ll<<endl;
		}
		else{
			int path = hgt[a] - hgt[u] + hgt[b] - hgt[u];
			ll ted = 1ll * kid[a] * kid[b];
			ll sum = 1ll * (ted * path + 1ll * kid[a] * dis[b] + 1ll * kid[b] * dis[a]);
			cout<<fixed<<setprecision (10)<<(double)sum / ted + 1ll<<endl;
		}
	}
	return 0;
}