#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, m, n) for(int i=int(m); i<n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 100100100100;
const int MOD = 1000000007;

struct Edge{
  int id, to;
  Edge(int i, int t): id(i), to(t) {}
};
using Graph = vector<vector<Edge>>;

Graph G;
ll path;

bool dfs(int v, int p, int v2){
  if (v == v2) return true;
  for (auto e : G[v]) {
    if (e.to == p) continue;
    if (dfs(e.to, v, v2)) {
      path |= 1ll<<e.id;
      return true;
    }
  }
  return false;
}

int main(){
  int N; cin >> N;
  G = Graph(N);
  rep(i, N-1){
    int a, b; cin >> a >> b;
    a--; b--;
    G[a].push_back(Edge(i, b));
    G[b].push_back(Edge(i, a));
  }

  int M; cin >> M;
  vector<ll> paths(M);
  rep(i, M){
    int u, v; cin >> u >> v;
    u--, v--;
    path = 0;
    dfs(u, -1, v);
    paths[i] = path;
  }
  
  
  ll ans = 0;
  rep(i, 1ll<<M){
    ll eset = 0;
    rep(j, M) {
      if (i>>j & 1) {
        eset |= paths[j];
      }
    }
    ll num = 1ll<<(N-1 - __builtin_popcountll(eset));
    if(__builtin_popcountll(i) % 2 == 0) ans += num;
    else ans -= num;
  }
  cout << ans << endl;
  return 0;
}