#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

vector<pii> g[55];
long long bits[1<<20];

bool dfs(int u, int p, int f, int j){
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i].first, idx = g[u][i].second;
        if(v == p) continue;
        if(v == f){
            bits[1<<j] |= (1ll<<idx);
            return 1;
        }
        if(dfs(v, u, f, j)){
            bits[1<<j] |= (1ll<<idx);
            return 1;
        }
    }
    return 0;
}
int main(){
    int n, m;
    scanf("%d", &n);
    for(int i=0;i<n-1;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(pii(b, i));
        g[b].push_back(pii(a, i));
    }
    scanf("%d", &m);
    for(int i=0;i<m;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        dfs(a, 0, b, i);
    }
    for(int i=1;i<(1<<m);i++){
        if(__builtin_popcount(i) == 1) continue;
        for(int j=0;j<m;j++){
            if((i>>j)&1) bits[i] |= bits[1<<j];
        }
    }

    LL ans = (1ll<<(n-1));
    for(int i=1;i<(1<<m);i++){
        int cnt = n-1-__builtin_popcountll(bits[i]);
        if(__builtin_popcount(i)%2 == 1){
            ans = (ans - (1ll<<cnt));
        }
        else{
            ans = (ans + (1ll<<cnt));
        }
    }
    printf("%lld\n", ans);
}