#include<bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned long long;using pii=pair<int,int>;using i128=__int128_t;
#define all(x) x.begin(),x.end()
#define mem0(x) memset(x,0,sizeof(x))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define errorf(...) fprintf(stderr, __VA_ARGS__)
#define endl '\n'
#define pb push_back
inline int read(){int f=1,x=0;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}while(isdigit(c)){x=x*10+c-'0';c=getchar();}return x*f;}
template <class T> inline T read(){T f=1,x=0;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}while(isdigit(c)){x=x*10+c-'0';c=getchar();}return x*f;}
template <class T> void write(T x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+'0');}
using ld=double;
const int N = 1e6+5;
vector<int> G[N];
int fa[N],bdfn[N],sz[N],st[N];
int tot;
struct Node{
ld a;
ld taga;
}t[N*4];
void pushup(int o){
t[o].a=t[o<<1].a+t[o<<1|1].a;
}
void upd(int o,int l,int r,ld qa){
t[o].a+=qa*(r-l+1),t[o].taga+=qa;
}
void build(int o,int l,int r){
t[o]={0,0};
if(l==r)return;
int lch=o<<1,rch=o<<1|1;
int mid=(l+r)>>1;
build(lch,l,mid),build(rch,mid+1,r);
}
void pushdown(int o,int l,int r){
if(t[o].taga){
int mid=(l+r)>>1;
upd(o<<1,l,mid,t[o].taga);
upd(o<<1|1,mid+1,r,t[o].taga);
t[o].taga=0;
}
}
void add(int o,int l,int r,int ql,int qr,ld qa){
if(ql>qr)return;
if(ql<=l&&r<=qr)return upd(o,l,r,qa);
pushdown(o,l,r);
int lch=o<<1,rch=o<<1|1;
int mid=(l+r)>>1;
if(ql<=mid)add(lch,l,mid,ql,qr,qa);
if(qr>mid)add(rch,mid+1,r,ql,qr,qa);
pushup(o);
}
ld query(int o,int l,int r,int qi){
if(qi<l || qi>r)return 0;
if(l==r)return t[o].a;
pushdown(o,l,r);
int lch=o<<1,rch=o<<1|1;
int mid=(l+r)>>1;
if(qi<=mid)return query(lch,l,mid,qi);
return query(rch,mid+1,r,qi);
}
void bdfs(int u,int f){
fa[u]=f;
for(int v:G[u]){
if(v==f)continue;
bdfn[v]=++tot;
if(!st[u])st[u]=tot;
sz[u]++;
}
for(int v:G[u]){
if(v==f)continue;
bdfs(v,u);
}
}
void solve(){
int n=read(),c=read();
for(int i=1;i<n;i++){
int u=read(),v=read();
G[u].push_back(v);G[v].push_back(u);
}
tot=1;bdfn[1]=1;
bdfs(1,0);
build(1,1,n);
add(1,1,n,bdfn[c],bdfn[c],1);
int m=read();
ld ans = 0;
for(int i=1;i<=m;i++){
int x=read();
auto a = query(1,1,n,bdfn[x]);
ans += a;
add(1,1,n,bdfn[x],bdfn[x],-a);
if(sz[x] + (fa[x]!=0) == 0){
return 0;
}
a /= (sz[x]+(fa[x]!=0));
if(sz[x])add(1,1,n,st[x],st[x]+sz[x]-1,a);
if(fa[x])add(1,1,n,bdfn[fa[x]],bdfn[fa[x]],a);
}
for(int i=1;i<=n;i++)G[i].clear(),sz[i]=0;
printf("%.8f\n",ans);
}
int main(){
int T=read();
while(T--)solve();
return 0;
}