#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 55, M = 22;
set <int> st[M];
vector <pair <int, int> > v[N];
vector <int> path;
int a[N], b[N], n, m, rstrct, u1[M], u2[M];

void dfs(int x, int par) {
	if (x == u2[rstrct]) {
		for (int y : path) {
			st[rstrct].insert(y);
		}
		return;
	}
	for (auto y : v[x]) {
		if (y.fi != par) {
			path.pb(y.se);
			dfs(y.fi, x);
			path.pop_back();
		}
	}
}

bool vis[N];

ll rec(int x, int mask) {
	if (x == m) {
		memset(vis, 0, sizeof vis);
		int cnt = __builtin_popcount(mask), tot = n - 1;
		for (int i = 0; i < m; i++) {
			if ((1 << i) & mask) {
				for (int j : st[i]) {
					if (!vis[j]) {
						vis[j] = true;
						tot--;
					}
				}
			}
		}
		return (1LL << tot) * ((cnt & 1) ? -1 : 1);
	}
	return rec(x + 1, mask) + rec(x + 1, mask | (1 << x));
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
		scanf("%d %d\n", &a[i], &b[i]);
		v[a[i]].pb({b[i], i});
		v[b[i]].pb({a[i], i});
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &u1[i], &u2[i]);
		rstrct = i;
		dfs(u1[i], u1[i]);
		path.clear();
	}
	printf("%lld", rec(0, 0));
    return 0;
}
