#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#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>
#include <limits>
#include "limits.h"
 
#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 Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
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(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%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,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!=par){
        dfs(e,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<ll>>& 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];
  }

};

ll popcount(ll 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<ll>> graph(n);

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

  LowestCommonAncestor temp(graph,0);

  ll m;
  std::cin>>m;

  std::vector<ll> u(m),v(m),lca(m);

  rep(i,0,m){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    u[i]=a;v[i]=b;
    lca[i]=temp.query(a,b);
  }

  ll ans=0;

  rep(bit,0,1ll<<m){
    std::vector<ll> sum(n,0);
    rep(i,0,m){
      if((bit>>i)&1){
        sum[u[i]]++;
        sum[v[i]]++;
        sum[lca[i]]-=2;
      }
    }

    auto f=[&](auto f,ll now,ll par)->void{
      for(ll e:graph[now]){
        if(e==par)continue;
        f(f,e,now);
        sum[now]+=sum[e];
      }
    };
    f(f,0,-1);

    ll cnt=0;
    rep(i,0,n)if(sum[i]>0)cnt++;
    if(popcount(bit)%2)ans-=1ll<<(n-1-cnt);
    else ans+=1ll<<(n-1-cnt);
  }

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

  return 0;
}


Measured memory_bytes: 384