#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

#define MAXN 51 
#define level 18

int modpower(int n, int k)
{
	int res = 1;
	while(k>0)
	{
		if (k&1) res = res*n;
		k>>=1;
		n = n*n;
	}
	return res;
} 
  
vector <int> tree[MAXN]; 
int depth[MAXN]; 
int parent[MAXN][level]; 
int par[MAXN];
  
// pre-compute the depth for each node and their 
// first parent(2^0th parent) 
// time complexity : O(n) 
void dfs(int cur, int prev) 
{ 
    depth[cur] = depth[prev] + 1; 
    parent[cur][0] = prev; 
    for (int i=0; i<tree[cur].size(); i++) 
    { 
        if (tree[cur][i] != prev)
        {
        	par[tree[cur][i]] = cur;
            dfs(tree[cur][i], cur); 
        }
    } 
} 
  
// Dynamic Programming Sparse Matrix Approach 
// populating 2^i parent for each node 
// Time complexity : O(nlogn) 
void precomputeSparseMatrix(int n) 
{ 
    for (int i=1; i<level; i++) 
    { 
        for (int node = 1; node <= n; node++) 
        { 
            if (parent[node][i-1] != -1) 
                parent[node][i] = 
                    parent[parent[node][i-1]][i-1]; 
        } 
    } 
} 
  
// Returning the LCA of u and v 
// Time complexity : O(log n) 
int lca(int u, int v) 
{ 
    if (depth[v] < depth[u]) 
        swap(u, v); 
  
    int diff = depth[v] - depth[u]; 
  
    // Step 1 of the pseudocode 
    for (int i=0; i<level; i++) 
        if ((diff>>i)&1) 
            v = parent[v][i]; 
  
    // now depth[u] == depth[v] 
    if (u == v) 
        return u; 
  
    // Step 2 of the pseudocode 
    for (int i=level-1; i>=0; i--) 
        if (parent[u][i] != parent[v][i]) 
        { 
            u = parent[u][i]; 
            v = parent[v][i]; 
        } 
  
    return parent[u][0]; 
} 

void mark(int x, int y, vector <int> &vis)
{
	// debug1(y);
	if (x==y)
		return;
	vis[y] = 1;
	if (par[y]==x || par[y]==-1)
		return;
	mark(x, par[y], vis);
}

signed main()
{
	// ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	for (int i=0;i<n-1;++i)
	{
		int u, v;
		cin>>u>>v;
		tree[u].pb(v);
		tree[v].pb(u);
	}
	par[1] = -1;
	dfs(1, 0);
	precomputeSparseMatrix(n); 
	int m;	
	cin>>m;
	vector <pair <int, int>> v(m);
	for (int i=0;i<m;++i)
	{
		cin>>v[i].F>>v[i].S;
	}
	int N = (1ll<<m)-1;
	vector <int> ans(N+1);
	int res = 0;
	for (int mask = 0;mask<=N;++mask)
	{
		vector <int> vis(n+1, 0);
		for (int j=0;j<m;++j)
		{
			if (mask&(1ll<<j))
			{
				int x = lca(v[j].F, v[j].S);
				// if (mask==2)
				// debug3(x, v[j].F, v[j].S);
				mark(x, v[j].F, vis);
				mark(x, v[j].S, vis);
			}
		}
		int c=0;
		for (int i=2;i<=n;++i)
		{
			if (vis[i])
				c++;
		}
		// debug2(mask, n-1-c);
		ans[mask] = modpower(2, (int)(n-1-c));
		int set_bits = __builtin_popcount(mask);
		if (set_bits&1)
		{
			res-=ans[mask];
		}
		else
		{
			res+=ans[mask];
		}
	}
	cout<<res<<"\n";





	return 0;
}

Measured memory_bytes: 8448