#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const int N = 55;
vector< vll > graph(N);
ll val[N];
vector< pll > con;
ll n, m;
int anc[N][10];
int ctr = 0;
int tin[N], tout[N];
bool is_ancestor(int a, int b)
{
    if( tin[a] <= tin[b] && tout[b] <= tout[a]) return true;
    return false;
}
int lca(int a, int b)
{
    if(is_ancestor(a, b)) return a;
    if(is_ancestor(b, a)) return b;
    int i;
    FORD(i, 6, 0)
    {
        if(!is_ancestor(anc[a][i], b))
            a = anc[a][i];
    }
    return anc[a][0];
}
void dfs(int i, int p)
{
    tin[i] = ctr++;
    int j, si = graph[i].size();
    anc[i][0] = p;
    FOR(j, 1, 7)
        anc[i][j] = anc[anc[i][j-1]][j-1];
    FOR0(j, si)
    {
        int v = graph[i][j];
        if( v == p) continue;
        dfs(v, i);
    }
    tout[i] = ctr++;
}
ll dfs2(int i, int p)
{
    int j, si = graph[i].size();
    ll ans = 0;
    FOR0(j, si)
    {
        int v = graph[i][j];
        if( v == p) continue;
        ans += dfs2(v, i);
        val[i] += val[v];
    }
    if( val[i] > 0) ans++;
    return ans;
}
ll bcount(ll a)
{
    ll cur = 1;
    ll ans = 0;
    ll i;
    FOR0(i, 32)
    {
        if( a < cur) break;
        if(a&cur) ans++;
        cur *= 2;
    }
    return ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n;
    ll i, j;
    FOR0(i, n-1)
    {
        ll u, v;
        cin>>u>>v;
        u--;
        v--;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    dfs(0, 0);
    cin>>m;
    FOR0(i, m)
    {
        ll u, v;
        cin>>u>>v;
        u--;
        v--;
        con.pb(mp(u, v));
    }
    ll ans1 = pow(2, n-1), ans2 = 0;
    ll super = pow(2, m);
    FOR(i, 1, super)
    {
        FOR0(j, n) val[j] = 0;
        int cur = 1;
        FOR0(j, m)
        {
            if(cur&i)
            {
                int a = lca(con[j].ff, con[j].ss);
                val[con[j].ff]++;
                val[con[j].ss]++;
                val[a] -= 2;
            }
            cur *= 2;
        }
        ll cval = n-1 - dfs2(0, 0);
        cval = pow(2, cval);
        if(bcount(i)%2)
            ans2 += cval;
        else 
            ans2 -= cval;
    }
    cout<<ans1-ans2<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 512