#include <cstdio>
#include <vector>
#include <utility>
#include <map>

/*
\cap_{u,v} \cup_{i\in (u,v) path} E_i

g(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} = N}|
G(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} \subseteq N}|
     = |{E | {u,v\in M-N | \cap_{i\in (u,v) path} !E_i}}|
*/

int n, m;
std::vector<int> E[50];

long long int M[20];
long long int A[1<<20];
std::map<std::pair<int, int>, int> edges;

long long int dfs(int u, int v, int p){
  if(u == v) return 0;
  for(int x: E[u]){
    if(x == p) continue;
    long long int b = dfs(x, v, u);
    if(b != -1) return (1LL << edges[{u, x}]) | b;
  }
  return -1;
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    E[a-1].push_back(b-1);
    E[b-1].push_back(a-1);
    edges[{a-1,b-1}] = i;
    edges[{b-1,a-1}] = i;
  }
  scanf("%d", &m);
  for(int i = 0; i < m; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    M[i] = dfs(a-1, b-1, -1);   
  }
  long long int ans = 1LL << (n-1);
  for(int i = 1; i < (1<<m); i++){
    A[i] = A[i&(i-1)] | M[__builtin_ctzll(i)];
    long long int x = 1LL << (n-1-__builtin_popcountll(A[i]));
    ans += (1-2*__builtin_parity(i))*x;
  }

  printf("%lld\n", ans);
  return 0;
}
