//expected 32
/*
Contest: NOI 2020
Problem: destiny
Author: tzc_wk
Time: 2020.8.18
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define pb			push_back
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define y1			y1010101010101
#define y0			y0101010101010
typedef pair<int,int> pii;
typedef long long ll;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-') neg=-1;
		c=getchar();
	}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*neg;
}
const ll MOD=1000000000000000000;
int n,m;
ll ans=0;
ll qpow(ll x,int e){
	ll ans=1;
	while(e){
		if(e&1) ans=ans*x%MOD;
		x=x*x%MOD;e>>=1;
	}
	return ans;
}
vector<int> g[500005];
int qu[23],qv[23];
struct node{
	int l,r,val,lz;
} s[500005<<2];
inline void build(int k,int l,int r){
	s[k].l=l;s[k].r=r;s[k].lz=-1;
	if(l==r) return;
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
}
inline void pushdown(int k){
	if(s[k].lz!=-1){
		s[k<<1].lz=s[k].lz;s[k<<1].val=(s[k<<1].r-s[k<<1].l+1)*s[k].lz;
		s[k<<1|1].lz=s[k].lz;s[k<<1|1].val=(s[k<<1|1].r-s[k<<1|1].l+1)*s[k].lz;
		s[k].lz=-1;
	}
}
inline void modify(int k,int l,int r,int x){
	if(l<=s[k].l&&s[k].r<=r){
		s[k].lz=x;s[k].val=(s[k].r-s[k].l+1)*x;
		return;
	}
	pushdown(k);
	int mid=(s[k].l+s[k].r)>>1;
	if(r<=mid) modify(k<<1,l,r,x);
	else if(l>mid) modify(k<<1|1,l,r,x);
	else modify(k<<1,l,mid,x),modify(k<<1|1,mid+1,r,x);
	s[k].val=s[k<<1].val+s[k<<1|1].val;
}
inline int query(int k,int l,int r){
	if(l<=s[k].l&&s[k].r<=r) return s[k].val;
	pushdown(k);
	int mid=(s[k].l+s[k].r)>>1;
	if(r<=mid) return query(k<<1,l,r);
	else if(l>mid) return query(k<<1|1,l,r);
	else return query(k<<1,l,mid)+query(k<<1|1,mid+1,r);
}
int dep[500005],fa[500005],wson[500005],top[500005],siz[500005],dfn[500005],tim=0;
inline void dfs1(int x,int f){
	fa[x]=f;siz[x]=1;
	foreach(it,g[x]){
		int y=*it;if(y==f) continue;
		dep[y]=dep[x]+1;dfs1(y,x);siz[x]+=siz[y];
		if(siz[y]>siz[wson[x]]) wson[x]=y;
	}
}
inline void dfs2(int x,int tp){
	top[x]=tp;dfn[x]=++tim;
	if(wson[x]) dfs2(wson[x],tp);
	foreach(it,g[x]){
		int y=*it;if(y!=fa[x]&&y!=wson[x]) dfs2(y,y);
	}
}
inline void jump(int x,int y,int z){
	if(dep[x]<dep[y]) swap(x,y);
	while(top[x]!=top[y]){
        if(dep[top[x]]<dep[top[y]]) swap(x,y);
		modify(1,dfn[top[x]],dfn[x],z);
		x=fa[top[x]];
	}
    if(dep[x]<dep[y]) swap(x,y);
	if(x!=y) modify(1,dfn[y]+1,dfn[x],z);
}
int main(){
//	freopen("destiny.in","r",stdin);
//	freopen("destiny.out","w",stdout);
	n=read();build(1,1,n);
	fz(i,1,n-1){int u=read(),v=read();g[u].pb(v);g[v].pb(u);}
	dfs1(1,0);dfs2(1,1);m=read();
//	for(int i=1;i<=n;i++) printf("%d %d %d %d %d %d\n",fa[i],dep[i],siz[i],wson[i],top[i],dfn[i]);
	fz(i,1,m) qu[i]=read(),qv[i]=read();
	for(int i=0;i<(1<<m);i++){
		for(int j=1;j<=m;j++) if(i>>(j-1)&1) jump(qu[j],qv[j],1);
		int cnt=__builtin_popcount(i),sum=n-1-query(1,1,n);
		if(cnt&1) ans=(ans-qpow(2,sum)+MOD)%MOD;
		else ans=(ans+qpow(2,sum))%MOD;
		for(int j=1;j<=m;j++) if(i>>(j-1)&1) jump(qu[j],qv[j],0);
	}
	printf("%lld\n",ans);
	return 0;
}
/*1
5
1 2
2 3
3 4
3 5
2
1 3
2 5
*/
/*2
15
2 1
3 1
4 3
5 2
6 3
7 6
8 4
9 5
10 7
11 5
12 10
13 3
14 9
15 8
6
3 12
5 11
2 5
3 13
8 15
1 13
*/

Measured memory_bytes: 15456