#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

/*
 *　ほうじょっぽい
 * どれか0個のパスすべてが白で残りはどうでもいい→足す
 * どれか1つのパスすべてが白で残りはどうでもいい→引く
 *
 * res = sum (-1)^k (すべてのk個のパスの選び方について通らない部分をnとしたとき2^nの和)
 *
 */
int64 N, M;
vector<PII> G[51];
vector<PII> es;
vector<PII> cond;
vector<PII> par;
vector<int64> dep;

void dfs(int64 v, int64 p, int64 d = 0, int64 idx = -1) {
  par[v] = {p, idx};
  dep[v] = d;
  for (auto& u : G[v]) {
    if (u.fs == p) continue;
    dfs(u.fs, v, d+1, u.sc);
  }
}

int64 calc(int64 bit) {
  vector<int64> col(N, 0);
  using T = tuple<int64, int64, int64, int64>;
  priority_queue<T> pq;
  vector<set<PII>> sts(N);
  REP(i, M) {
    if (bit >> i & 1) {
      pq.emplace(dep[cond[i].fs], cond[i].fs, cond[i].fs, cond[i].sc);
      pq.emplace(dep[cond[i].sc], cond[i].sc, cond[i].sc, cond[i].fs);
      sts[cond[i].fs].insert({cond[i].fs, cond[i].sc});
      sts[cond[i].sc].insert({cond[i].sc, cond[i].fs});
    }
  }
  while (pq.size()) {
    int64 d, v, v1, v2;
    tie(d, v, v1, v2) = pq.top(); pq.pop();
    if (sts[v].find({v1, v2}) == sts[v].end()) continue;
    col[par[v].sc] = 1;
    v = par[v].fs;
    if (sts[v].find({v2, v1}) != sts[v].end()) {
      sts[v].erase({v2, v1});
    } else {
      sts[v].insert({v1, v2});
      if (d-1 != 0) pq.emplace(d-1, v, v1, v2);
    }
  }
  int64 cnt = 0;
  REP(i, N-1) {
    cnt += 1-col[i];
  }
//  cout << bitset<3>(bit) << ": ";
//  REP(i, N-1) {
//    cout << col[i] << " ";
//  }
//  cout << endl;
  return cnt;
}

int64 use_edge(int64 u, int64 v) {
  int64 bit = 0;
  while (u != v) {
    if (dep[u] < dep[v]) swap(u, v);
    bit |= (1LL << par[u].sc);
    u = par[u].fs;
  }
  return bit;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	REP(i, N-1) {
	  int64 a, b;
	  cin >> a >> b; a--; b--;
	  G[a].emplace_back(b, i);
	  G[b].emplace_back(a, i);
	  es.emplace_back(a, b);
	}
	par.resize(N); dep.resize(N, 0);
	dfs(0, 0);
	cin >> M;
	cond.resize(M);
	vector<int64> use_e(M, 0);
	REP(i, M) {
	  cin >> cond[i].fs >> cond[i].sc; cond[i].fs--; cond[i].sc--;
	  use_e[i] = use_edge(cond[i].fs, cond[i].sc);
	}

	int64 res = 0;
	vector<int64> sum(M+1, 0);
	REP(i, 1LL << M) {
	  int64 bits = __builtin_popcountll(i);
	  int64 edges = 0;
	  REP(j, M) {
	    if (i >> j & 1)  edges |= use_e[j];
	  }
	  int64 ret = (N-1)-__builtin_popcountll(edges);

//	  cout << bits << " += " << (1LL << ret) << endl;
	  sum[bits] += (1LL << ret);
	}
	REP(i, M+1) {
	  res += (i % 2 ? -1 : 1) * sum[i];
	}
	cout << res << endl;
}
// ...............................................................................................????????????????????
//おつかれさまでした..................

Measured memory_bytes: 384