#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define pii pair<int, int>
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline ll pwm(ll xx, ll pow, ll MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return  mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow - 1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2 * pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow - 1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}

/*-----------------------------------------------------MATH------------------------------------------------*/
ll mod = 1e16;
vector<ll> S;
vector<ll> N;
vector<vector<int>> vert;
vector<pii> q;
vector<int> parent(51);
vector<bool> was(51, false);
int ours[51][51];
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(!was[son]) dfs(son ,v);
    }
}
vector<bool> shit(51, false);
int lol(int bit, int m, int n){
    shit.clear();
    shit.resize(n);
    /*cout<<"here"<<bit<<endl;
    cout.flush();*/
    for(int i=0;i<m;i++){
        if((bit>>i)&1){
            int u=q[i].first;
            int v=q[i].second;
            int p=ours[u][v];
           /* cout<<v<<" "<<u<<" "<<p<<endl;
            cout.flush();*/
            while(u!=p){
                shit[u]=true;
                //cout.flush();
                u=parent[u];
            }
            while(v!=p){
                shit[v]=true;
               // cout.flush();
                v=parent[v];
            }
        }
    }
    int ans=0;
    for(int i=1;i<n;i++){
        if(!shit[i]) ans++;
    }
    return ans;
}
void solve() {
    int n;
    cin >> n;
    vert.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        vert[a].push_back(b);
        vert[b].push_back(a);
    }
    int m;
    cin>>m;
    q.resize(m);
    S.resize(m+1);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        q[i]={u,v};
    }
    dfs(0, -1);
    for(int i=0;i<n;i++){
        ours[i][i]=i;
        for(int j=i+1;j<n;j++){
            vector<int> f;
            vector<int> s;
            int u=i;
            int v=j;
            while(u!=-1){
                f.push_back(u);
                u=parent[u];
            }
            while(v!=-1){
                s.push_back(v);
                v=parent[v];
            }
            for(int l=s.size()-1, t=f.size()-1; t>=0 && l>=0 ;t--, l--){
                if((l==0 || t==0) && s[l]==f[t]){
                    ours[i][j]=s[l];
                    break;
                }
                else if(s[l]!=f[t]){
                    ours[i][j]=s[l+1];
                    break;
                }
            }
            ours[j][i]=ours[i][j];
           // cout<<i<<" "<<j<<" "<<ours[i][j]<<endl;
        }
    }

    for(int i=0;i<(1<<m);i++){
        int b=__builtin_popcount(i);
        int lost=lol(i,m,n);//remaining
      //  cout<<b<<" "<<lost<<" "<<i<<endl;
        S[b]+=pwm(2,lost,mod);
    }
    ll ans=0;
    for(int i=0;i<m+1;i++){
        ans+=((i%2==0)*2-1)*S[i];
    }
    cout<<ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 256