/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<lpair> tree[55];
ll parent[100] = {};
ll depth[100] = {};
ll next_val[25][100] = {};
ll logN = 0;
ll sum[100] = {};
ll N;
void dfs2(ll cur, ll par, ll d){
	if(par != -1) sum[cur] = sum[par] + d;
	for(auto &e: tree[cur]){
		if(e.first == par) continue;
		dfs2(e.first, cur, e.second);
	}
}

void dfs(ll cur, ll par, ll d){
	depth[cur] = d;
	parent[cur] = par;
	for(auto &e: tree[cur]){
		if(e.first == par) continue;
		dfs(e.first, cur, d+1);
	}
}

ll get_parent(ll cur, ll num) {
    ll p = cur;
    rrep(k,logN-1, 0){
        if(p == -1){
            break;
        }
        if((num >> k) & 1){
            p = next_val[k][p];
        }
    }
    return p;
}

ll get_LCA(ll va, ll vb){
	if(depth[va] > depth[vb]){
		va = get_parent(va, depth[va] - depth[vb]);
	}else if(depth[va] < depth[vb]){
		vb = get_parent(vb, depth[vb] - depth[va]);
	}
	ll lv = -1, rv = N+1;
	while(rv - lv > 1){
		ll mid = (rv + lv) / 2;
		ll ta = get_parent(va, mid);
		ll tb = get_parent(vb, mid);
		if(ta == -1 || tb == -1){
			rv = mid;
		}else if(ta != tb){
			lv = mid;
		}else{
			rv = mid;
		}
	}
	return get_parent(va, rv);
}

ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x, n/2);
    if(n % 2 == 1) res = res * x;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    logN = floor(log2(N)) + 1;
    ll a[55], b[55];
    map<lpair, ll> mp;
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        mp[{a[i], b[i]}] = i;
        mp[{b[i], a[i]}] = i;
        tree[a[i]].push_back({b[i],1});
        tree[b[i]].push_back({a[i],1});
    }

    ll M;
    cin >> M;
    ll u[25], v[25];
    rep(i,0,M){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
    }
	dfs(0, -1, 0);
    rep(i,0,N){
        next_val[0][i] = parent[i];
    }
    rep(k,0,logN){
        rep(i,0,N){
            if(next_val[k][i] == -1){
                next_val[k+1][i] = -1;
            }else{
                next_val[k+1][i] = next_val[k][next_val[k][i]];
            }
        }
    }
	dfs2(0,-1,0);
    ll ans = 0;
    vector<ll> edge_use[25];
    rep(i,0,M){
        ll pa = get_LCA(u[i], v[i]);
        ll cur = u[i];
        while(cur != pa){
            ll nxt = get_parent(cur, 1);
            edge_use[i].push_back(mp[{cur, nxt}]);
            cur = nxt;
        }
        cur = v[i];
        while(cur != pa){
            ll nxt = get_parent(cur, 1);
            edge_use[i].push_back(mp[{cur, nxt}]);
            cur = nxt;
        }
    }

    // rep(i,0,M){
    //     for(auto &e: edge_use[i]){
    //         print(e);
    //     }
    //     cout << "---" << endl;
    // }

    rep(bit,1,(1LL<<M)){
        ll cnt = __builtin_popcount(bit);
        ll check[55] = {};
        rep(i,0,M){
            if((bit>>i) & 1){
                for(auto &e: edge_use[i]){
                    check[e] = 1;
                }
            }
        }
        ll check_cnt = 0;
        rep(i,0,N-1){
            if(check[i] > 0) check_cnt++;
        }
        check_cnt = N-1 - check_cnt;
        ll res = power(2, check_cnt);
        if(cnt % 2 == 1){
            ans += res;
        }else{
            ans -= res;

        }
    }
    ans = power(2,N-1) - ans;
    print(ans);

    

}

Measured memory_bytes: 384