#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 110
vector<int> pre_G[MAX_N];
vector<int> G[MAX_N];
int par_[MAX_N];
int flag_netsukigi[MAX_N];
int depth[MAX_N];
void make_netsukigi(int r){
    queue<int> que;
    que.push(r);
    flag_netsukigi[r] = 1;
    par_[r] = -1;
    depth[r] = 0;
    while(que.size() > 0){
        int x = que.front();
        que.pop();
        flag_netsukigi[x] = 1;
        rep(i,pre_G[x].size()){
            if(flag_netsukigi[pre_G[x][i]] == 0){
                par_[pre_G[x][i]] = x;
                depth[pre_G[x][i]] = depth[x] + 1;
                G[x].push_back(pre_G[x][i]);
                que.push(pre_G[x][i]);
            }
        }
    }
}

int lca(int u, int v){
    // cout << u << ' ' << v << endl;
    while(depth[u] > depth[v]) u = par_[u];
    while(depth[v] > depth[u]) v = par_[v];

    // cout << "YAY";

    while(u != v){
        u = par_[u];
        v = par_[v];
    }
    // cout << "YAY";
    return u;
}

int main() {
    int n;
    cin >> n;

    int a[n-1], b[n-1];

    map<P, int> mp;

    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        pre_G[a[i]].push_back(b[i]);
        pre_G[b[i]].push_back(a[i]);
        if(a[i] > b[i])swap(a[i], b[i]);
        mp[P(a[i], b[i])] = i;
    }

    make_netsukigi(0);

    int m;
    cin >> m;
    int u[m], v[m];
    rep(i,m){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
    }

    int key[m][n-1];
    rep(i,m)rep(j,n-1)key[i][j] = 0;

    // cout << "OK";

    rep(i,m){
        int w = lca(u[i], v[i]);
        int mm = depth[u[i]] - depth[w] + depth[v[i]] - depth[w] + 1;
        int l[mm];
        int ii = u[i], jj = v[i];
        int c = 0;
        // cout << "OK";
        while(true){
            l[c] = ii;
            c++;
            if(ii == w)break;
            ii = par_[ii];
        }
        c = mm - 1;
        // cout << "OK";
        while(true){
            l[c] = jj;
            c--;
            if(jj == w)break;
            jj = par_[jj];
        }
        rep(j,mm-1){
            int x = l[j];
            int y = l[j+1];
            if(x > y)swap(x, y);
            key[i][mp[P(x, y)]] = 1;
        }
    }

    // cout << "OK";

    ll two[55] = {};
    two[0] = 1;
    srep(i,1,55)two[i] = two[i-1] * 2;

    ll ans = 0;
    
    rep(i,(1<<m)){
        int f[m] = {};
        int ii = i;
        int ff = 0;
        rep(j,m){
            f[j] = ii % 2;
            ii /= 2;
            ff += f[j];
        }
        int pp[n-1] = {};
        rep(j,m){
            if(f[j]){
                rep(k,n-1){
                    if(key[j][k])pp[k] = 1;
                }
            }
        }
        int cnt = 0;
        rep(k,n-1){
            cnt += pp[k];
        }
        ll tmp = two[n-1-cnt];
        if(ff % 2 == 0){
            ans += tmp;
        }else{
            ans -= tmp;
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256