#include<bits/stdc++.h>
#define N 55
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define ll long long
using namespace std;
inline void in(int &x)
{
	x=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
bool edge[N][N];
ll dp[N][1<<20];
int state[N];
int n,m,fa[N],dep[N];
void dfs(int from,int f)
{
	fa[from]=f;
	dep[from]=dep[f]+1;
	for(int to=1;to<=n;++to)
	if(to!=f&&edge[from][to])
	dfs(to,from);
}
void LCA(int x,int y,int i)
{
	while(x!=y)
	{
		if(dep[x]<dep[y])swap(x,y);
		state[x]|=1<<i;
		x=fa[x];
	}
}
int main()
{
	in(n);
	for(int i=1;i<n;++i)
	{
		int x,y;
		in(x);in(y);
		edge[x][y]=edge[y][x]=1;
	}
	dfs(1,0);
	in(m);
	for(int i=0;i<m;++i)
	{
		int x,y;
		in(x);in(y);
		LCA(x,y,i);
	}
	dp[2][0]=1;
	for(int i=2;i<=n;++i)
	for(int mask=0;mask<(1<<m);++mask)
	{
		dp[i+1][mask]+=dp[i][mask];
		dp[i+1][mask|state[i]]+=dp[i][mask];
	}
	printf("%lld\n",dp[n+1][(1<<m)-1]);
	return 0;
}