#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll facmemo[200000] = {};

ll factorial(ll n) {//階乗
	if (facmemo[n] != 0) return facmemo[n];
	if (n == 0) return 1;
	ll ret = n * factorial(n - 1);
	ret %= MODU;
	return facmemo[n] = ret;
}

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1LL;
	}
	return res;
}

bool sankaku(int a, int b, int c) {
	return a <= b + c && b <= a + c && c <= b + a;
}

signed main() {
	int n, m;
	cin >> n;
	Graph g(n);
	vector<int> depth(n), tag(n), nex(n);

	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back({ a,b });
		g[b].push_back({ b,a });
	}

	function<void(int, int, int)> dfs = [&](int par, int cur, int d) {
		depth[cur] = d;
		nex[cur] = par;
		for (auto ed : g[cur]) {
			if (ed.to == par) continue;
			dfs(cur, ed.to, d + 1);
		}
		return;
	};
	dfs(0, 0, 0);

	cin >> m;
	vector<pii> e(m);
	REP(i, m) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		e[i] = { u,v };


		int cu = u, cv = v;
		while (cu != cv) {
			bitset(tag[cu], i);
			bitset(tag[cv], i);
			if (depth[cu] > depth[cv]) {
				cu = nex[cu];
			}
			else cv = nex[cv];
		}
		bitunset(tag[cu], i);
	}

	int loopc = 1 << m;
	ll ans = 0;

	rep(i, 1, loopc) {
		int used[51] = {};
		int k = 0;
		int cou = 0;
		REP(j, m) {
			k += bitcheck(i, j);
		}

		REP(j, n) {
			if (i & tag[j]) {
				cou++;
			}
		}

		ll cans = mod_pow(2, n - 1 - cou);
		ans += cans * ((k % 2) * 2 - 1);
	}

	ans = mod_pow(2, n - 1) - ans;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256