#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 
const int N=60;
vi adj[N];
const int R=N*N/2;
// int ru[]
int parent[N];
vector<pii> res;
// int dp[N][R][2];
vector<vi > paths(R);
// vector<int> z;
int dest,n,m;
bool dfs(int v,int p,int in){
    parent[v]=p;
    if(v==dest) {paths[in].pb(v);return 1;}
    for(auto i:adj[v]){
        if(i==p) continue;
        if(dfs(i,v,in)){
            paths[in].pb(v);
            return 1;
        }
    }
    return 0;
}

int solve(){

    cin>>n;
    int graph[n+1][n+1];
    memset(graph,0,sizeof(graph));
    rep0(n-1){
        int u,v;cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        graph[u][v]=graph[v][u]=i;
        res.pb({u,v});
        // graph[u]

    }
    // int m;
    cin>>m;
    rep0(m){
        int x,y;cin>>x>>y;
        // res.pb({x,y});
        dest=y;
        dfs(x,-1,i);
    }
    // int dp[(1<<m)+10];

    // memset(dp,0,sizeof(dp));
    int ans=0;
    for(int mask=0;mask<(1<<m);mask++){
        int vis[n+1];
        int cnt=0;
        memset(vis,0,sizeof(vis));
        for(int bit=0;bit<m;bit++){
            if((1ll<<bit) & mask){
                cnt++;
                for(int i=0;i<paths[bit].size()-1;i++) vis[graph[paths[bit][i]][paths[bit][i+1]]]=1;
            }
        }
        int count=n-1;
        for(int i=0;i<n-1;i++) count-=vis[i];

        // for(auto i:res) if(vis[i.ff] && vis[i.ss]) count--;
        // for(int i=1;i<=n;i++) count+=vis[i];
        // count--;
        // count=max(0,count);
        // count=n-1-count;
        // trace(ans);
        if(cnt % 2 == 0)ans+=(1ll<<count);
        else ans-=(1ll<<count);
        // trace(mask,count,ans,cnt,cnt & 1);
    }
    // ans=(1ll<<(n-1))-ans;
    cout<<ans;
   


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 384