#include <cassert>
#include "limits.h"
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename H,typename... T>
void debug_out(H head,T... tail){
  std::cerr<<" "<<head;
  debug_out(tail...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long,long long>;

//LowestCommonAncestor
//ダブリングを使う 前処理O(Nlog N),クエリO(log N)
class LowestCommonAncestor{
  using ll=long long;
  private:

  ll n,bit;
  std::vector<ll> depth;
  std::vector<std::vector<ll>> par_doubling;
  std::vector<std::vector<P>> graph;

  ll getbit(ll temp){
    ll a=1;
    while(temp>0){
      a++;
      temp>>=1;
    }
    return a;
  }

  void dfs(ll now,ll par,ll dep){
    depth[now]=dep;
    if(par!=-1)par_doubling[now][0]=par;
    else par_doubling[now][0]=now;

    for(auto e:graph[now]){
      if(e.first!=par){
        dfs(e.first,now,dep+1);
      }
    }
  }

  void doubling(){
    for(ll i=1;i<bit;i++){
      for(ll j=0;j<n;j++){
        par_doubling[j][i]=par_doubling[par_doubling[j][i-1]][i-1];
      }
    }
  }

  public:

  //隣接リストのグラフと木の根を渡す
  LowestCommonAncestor(const std::vector<std::vector<P>>& g,ll root_):graph(g),n(g.size()),bit(getbit(g.size())),
                                                              depth(n),par_doubling(n,std::vector<ll>(bit)){
    dfs(root_,-1,0);
    doubling();
  }
  
  ll query(ll a,ll b){
    if(depth[a]<depth[b])std::swap(a,b);

    for(ll i=0;i<bit;i++){
      if(((depth[a]-depth[b])>>i)&1)a=par_doubling[a][i];
    }

    if(a==b)return a;

    for(ll i=bit-1;i>=0;i--){
      if(par_doubling[a][i]!=par_doubling[b][i]){
        a=par_doubling[a][i];
        b=par_doubling[b][i];
      }
    }

    return par_doubling[a][0];
  }

};

uint64_t popcount(uint64_t x){
  x = (x & 0x5555555555555555ULL) + ((x & 0xAAAAAAAAAAAAAAAAULL)>>1);
  x = (x & 0x3333333333333333ULL) + ((x & 0xCCCCCCCCCCCCCCCCULL)>>2);
  x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x & 0xF0F0F0F0F0F0F0F0ULL)>>4);
  x *= 0x0101010101010101ULL;
  return x >> 56;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll n;
  std::cin>>n;

  std::vector<std::vector<P>> graph(n);

  rep(i,0,n-1){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back({b,i});
    graph[b].push_back({a,i});
  }

  std::vector<uint64_t> tree(n,0);

  auto f=[&](auto f,ll now,ll par,uint64_t sum)->void{
    tree[now]=sum;
    for(auto next:graph[now]){
      if(next.first!=par){
        f(f,next.first,now,sum|(1ull<<next.second));
      }
    }
  };
  f(f,0,-1,0llu);

  LowestCommonAncestor lca(graph,0);

  ll m;
  std::cin>>m;

  std::vector<uint64_t> path(m);
  rep(i,0,m){
    ll u,v;
    std::cin>>u>>v;
    u--;v--;
    ll lc=lca.query(u,v);
    path[i]=(tree[u]|tree[v])^(tree[lc]);
  }

  ll ans=1ll<<(n-1);

  for(ll bit=(1ll<<m)-1;bit>0;bit--){
    uint64_t temp=0;
    rep(i,0,m)if((bit>>i)&1)temp|=path[i];
    if(popcount(bit)%2)ans-=1ll<<(n-1-popcount(temp));
    else ans+=1ll<<(n-1-popcount(temp));
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 256