#include <iostream>
#include <vector>
#include <functional>
using namespace std;
const int INF = 1001001001;

template<class M> struct SegmentTree
{
	int n;
	int size;
	vector<M> data;
	const function<M(M, M)> op;
	const M ID;

	SegmentTree(int n, function<M(M, M)> op, M id, const vector<M> &init_vals=vector<M>()) : n(n), op(op), ID(id) {
		size = 1;
		while (size < n) size <<= 1;
		data.assign(size * 2, ID);
		for (int i = 0; i < init_vals.size(); i++) data[size+i] = init_vals[i];
		for (int i = size-1; i > 0; i--) data[i] = op(data[2*i], data[2*i+1]);
	}
	
	void init(const vector<M> &init_vals) {
		data.assign(size * 2, ID);
		for (int i = 0; i < init_vals.size(); i++) data[size+i] = init_vals[i];
		for (int i = size-1; i > 0; i--) data[i] = op(data[2*i], data[2*i+1]);
	}
	
	void update(int idx, M x) {
		idx += size;
		data[idx] = x;
		while (idx /= 2) {
			data[idx] = op(data[2*idx], data[2*idx+1]);
		}
	}

	M query(int l, int r) {
		M L = ID, R = ID;
		for (l += size, r += size; l < r; l /= 2, r /= 2) {
			if (l & 1) L = op(L, data[l]), l++;
			if (r & 1) r--, R = op(data[r], R);
		}
		return op(L, R);
	}

	M val(int idx) {
		return data[size + idx];
	}

	vector<M> val_vec() {
		vector<M> res(n);
		for (int i = 0; i < n; i++) res[i] = data[size+i];
		return res;
	}
};

struct LCA
{
	struct RMQ {
		int val, idx;
	};
	static RMQ mymin(RMQ x, RMQ y) {
		if (x.val > y.val) return y;
		else return x;
	}
	RMQ id = RMQ{INF, -1};

	int n;
	int root;
	const vector<vector<int>> &g;
	vector<int> in;
	vector<int> euler_tour, depth_et;
	vector<int> dist_root;
	SegmentTree<RMQ> rmq;

	LCA(const vector<vector<int>> &g, int root) : n(g.size()), root(root), g(g), in(n), dist_root(n), rmq(2*n, mymin, id) {
		euler_tour.reserve(2 * n);
		depth_et.reserve(2 * n);
	}

	void init() {
		dfs(root, -1, 0);
		vector<RMQ> init_vals(2*n);
		for (int i = 0; i < 2*n; i++) {
			init_vals[i].val = depth_et[i];
			init_vals[i].idx = euler_tour[i];
		}
		rmq.init(init_vals);
	}

	void dfs(int v, int parent, int d) {
		in[v] = euler_tour.size();
		euler_tour.push_back(v);
		depth_et.push_back(d);
		dist_root[v] = d;
		for (int nv : g[v]) {
			if (nv == parent) continue;
			dfs(nv, v, d+1);
			euler_tour.push_back(v);
			depth_et.push_back(d);
		}
	}

	int lca(int u, int v) {
		int l = in[u], r = in[v];
		if (l > r) swap(l, r);
		return rmq.query(l, r+1).idx;
	}

	int dist(int u, int v) {
		int x = lca(u, v);
		return dist_root[u] + dist_root[v] - 2*dist_root[x];
	}
};

void dfs(int v, int parent, vector<vector<int>> &g, vector<int> &s, int &white) {
	for (int nv : g[v]) {
		if (nv == parent) continue;
		dfs(nv, v, g, s, white);
		s[v] += s[nv];
		if (s[nv] > 0) white++;
	}
}

int main() {
	long long n;
	cin >> n;
	vector<vector<int>> g(n);
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	LCA l(g, 0);
	l.init();
	long long m;
	cin >> m;
	vector<int> u(m), v(m), lca(m);
	for (int i = 0; i < m; i++) {
		cin >> u[i] >> v[i];
		u[i]--; v[i]--;
		lca[i] = l.lca(u[i], v[i]);
	}
	long long comp = 0;
	for (int bits = 1; bits < (1<<m); bits++) {
		bitset<32> t(bits);
		long long sign = -1;
		vector<int> s(n, 0);
		for (int j = 0; j < m; j++) {
			if (t[j]) {
				sign = -sign;
				s[u[j]] += 1;
				s[v[j]] += 1;
				s[lca[j]] -= 2;
			}			
		}
		int white = 0;
		dfs(0, -1, g, s, white);
		comp += sign * (1ll<<(n-1-white));
	}
	long long ans = (1ll<<(n-1)) - comp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3168