//#include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e18;;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
 
// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
vector<int> v[101];
set<pair<int,int>> s;
int par[101];
vector<int> gr[101][101];
int a[101][101];
void dfs(int u,int pari)
{
    for(int i=0;i<v[u].size();++i)
    {
        if(v[u][i]==pari)
            continue;
        par[v[u][i]]=u;
        dfs(v[u][i],u);
    }
}
void un(int src,int dest)
{
    memset(par,0,sizeof(par));
    dfs(src,0);
    vector<int> te;
    int x=dest;
    while(x!=src)
    {
        te.push_back(x);
        x=par[x];
    }
    te.push_back(src);
    reverse(te.begin(),te.end());
    for(auto i:te)
    {
        gr[src][dest].push_back(i);
    }
    a[src][dest]=gr[src][dest].size()-1;


}
int32_t main()
{
IOS

      
    
    int n;
    cin>>n;
    memset(a,0,sizeof(a));
    pair<int,int> p1[n];
    for(int i=1;i<=n-1;++i)
    {
        int x,y;
        cin>>x>>y;
        p1[i-1].first=max(x,y);
        p1[i-1].second=min(y,x);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
        {
            if(i==j)
                continue;
            un(i,j);
        }
    }
    int m;
    cin>>m;
    int pow[n+1];
    pow[0]=1;
    for(int i=1;i<=n;++i)
        pow[i]=pow[i-1]*2;
    pair<int,int> p[m+1];
    for(int i=0;i<m;++i)
        cin>>p[i].first>>p[i].second;
    int val=1;
    for(int i=1;i<=n-1;++i)
        val*=2;
    int ans=0;
 
    for(int i=1;i<(1ll<<m);++i)
    {
        vector<pair<int,int>> temp;
        int x=0;
        for(int j=0;j<m;++j)
        {
            if(i&(1ll<<j))
                temp.push_back({p[j].first,p[j].second}),x++;
        }
        int q=0;
        for(int j=0;j<n-1;++j)
         {
            
            
            int ch=0;
            int k=p1[j].first,l=p1[j].second;

            for(auto j1:temp)
            {
                if(a[j1.first][j1.second]-a[j1.first][k]-a[j1.second][l]==1 or a[j1.first][j1.second]-a[j1.first][l]-a[j1.second][k]==1)
                {
                    ch=1;
                    break;
                }
            }
            if(ch)
                q++;
 
            }
          
        int p=n-1-q;
        if(x%2==0)
        {
            ans-=pow[p];
        }
        else
            ans+=pow[p];
    }

    cout<<val-ans;



}       


Measured memory_bytes: 1152