#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 51;
int depth[nax];
int parent[nax];
vi za[nax];
vector<pii> edges;
vector<vi> used;

void visit(int v) {
	for (auto u : za[v]) {
		if (u == parent[v]) {
			continue;
		}
		depth[u] = depth[v] + 1;
		parent[u] = v;
		visit(u);
	}
}

void markEdge(int x, int father, int i) {
	pii szuk = minmax(x, father);
	// printf("looking for: %d, %d\n", szuk.st, szuk.nd);
	int edge_index = find(edges.begin(), edges.end(), szuk) - edges.begin();
	// printf("used[%d] adding: %d\n", i, edge_index);
	used[i].pb(edge_index);
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	edges.resize(n - 1);
	REP(i, n-1) {
		int x, y;
		cin >> x >> y;
		// printf("edges[%d] = %d, %d\n", i, edges[i].st, edges[i].nd);
		za[x].pb(y);
		za[y].pb(x);
		edges[i] = std::minmax(x, y);
		// printf("edges[%d] = %d, %d\n", i, edges[i].st, edges[i].nd);
	}
	int m;
	cin >> m;
	vector<pii> restrictions(m);
	used.resize(m);
	visit(1);
	REP(i, m) {
		cin >> restrictions[i].st >> restrictions[i].nd;
		int x = restrictions[i].st, y = restrictions[i].nd;
		while (depth[x] > depth[y]) {
			int father = parent[x];
			markEdge(x, father, i);
			x = father;
		}
		while (depth[x] < depth[y]) {
			int father = parent[y];
			markEdge(y, father, i);
			y = father;
		}
		while (x != y) {
			int fatherx = parent[x], fathery = parent[y];
			markEdge(x, fatherx, i);
			markEdge(y, fathery, i);
			x = fatherx;
			y = fathery;
		}
	}

	ll res = 0;
	FOR(mask, 1, (1 << m) - 1) {
		int znak = __builtin_popcount(mask) % 2 == 0 ? -1 : 1;
		vector<bool> wolne(n - 1, true);
		REP(i, m) if (mask & (1 << i)) {
			for (auto x : used[i]) {
				wolne[x] = false;
			}
		}
		int ileWolnych = 0;
		REP(i, n -1) ileWolnych += wolne[i];
		res += (1LL << ileWolnych)*znak;
	}
	// cout << res << endl;
	cout << (1LL << (n - 1)) - res << endl;
}

Measured memory_bytes: 3664