#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,set<T> a){
  os << "[ ";
  for (auto &&i : a)
  {
    os<< i << " ";
  }
  os<< " ]";
  return os;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,map<S,T> a){
  os << "[ ";
  for (auto &&i : a)
  {
    os<< i << " ";
  }
  os<< " ]";
  return os;
}
pll pllminmax(ll i,ll j){
  if(i>j){
    swap(i,j);
  }
  return pll(i,j);
}
void solve(long long N, std::vector<long long> a, std::vector<long long> b, long long M, std::vector<long long> u, std::vector<long long> v){
  vector<vector<ll>> tree(N);
  map<pll,ll> edges;
  REP(N-1){
    edges[pllminmax(a[i],b[i])]=i;
  }
  REP(a.size()){
    tree[a[i]].push_back(b[i]);
    tree[b[i]].push_back(a[i]);
  }
  vector<pll> parent(N);
  parent[0]=pll(-1,0);
  deque<ll> q;
  q.push_back(0);
  while(!q.empty()){
    auto tmp = q.front();q.pop_front();
    for (auto &&i : tree[tmp])
    {
      if(i==parent[tmp].first){
        continue;
      }
      parent[i]=pll(tmp,parent[tmp].second+1);
      q.push_back(i);
    }
  }
  dump(parent);
  vector<bitset<50>> paths(M);
  auto path=[&](ll i,ll j){
    if(parent[i].second<parent[j].second){
      swap(i,j);
    }
    set<ll> ret;
    while(parent[i].second>parent[j].second){
      ret.insert(edges[pllminmax(i,parent[i].first)]);
      i=parent[i].first;
    }
    while(i!=j){
      ret.insert(edges[pllminmax(i,parent[i].first)]);
      ret.insert(edges[pllminmax(j,parent[j].first)]);
      i=parent[i].first;
      j=parent[j].first;
    }
    return ret;
  };
  REP(M){
    auto tmp=path(u[i],v[i]);
    for (auto &&j : tmp)
    {
      paths[i].set(j);
    }
  }
  dump(edges);
  dump(paths);
  ull ans=(0);
  REP((1LL<<M)){
    bitset<50> white;
    For(j,M){
      if((1LL<<j)&i){
        dump(j);
        white|=paths[j];
      }
    }
    if(__builtin_popcountll(i)%2){
      ans-=(1LL<<(N-1-white.count()));
    }else{
      ans+=(1LL<<(N-1-white.count()));
    }
    dump(i);
    dump(white);
    dump(ans);
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        --a[i];
        --b[i];
    }
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
        --u[i];
        --v[i];
    }
    solve(N, std::move(a), std::move(b), M, std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 384