#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;
vi adj[51];int tin[51],tout[51],Time;
int up[51][8];int lc[51][51];
int cnt[51];
void dfs(int u,int p)
{
    tin[u]=Time++;
    up[u][0]=p;
    for(int i=1;i<8;i++)
        up[u][i]=up[up[u][i-1]][i-1];
    for(int v:adj[u])
    {
        if(v!=p)
        {
            dfs(v,u);
        }
    }
    tout[u]=Time++;
}
bool is_ancestor(int u,int v)
{
    return (tin[u]<=tin[v]&&tout[u]>=tout[v]);
}
int lca(int u,int v)
{
    if(is_ancestor(u,v))
        return u;
    if(is_ancestor(v,u))
        return v;
    for(int i=7;i>=0;i--)
        if(!is_ancestor(up[u][i],v))
            u=up[u][i];
    return up[u][0];
}
void dfs1(int u,int p)
{
    for(int v:adj[u])
    {
        if(v!=p)
        {
            dfs1(v,u);
            cnt[u]+=cnt[v];
            
        }
    }
}
void solve()
{
    int n;
    cin>>n;
    int u,v;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    Time=0;
    dfs(1,1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            lc[i][j]=lca(i,j);
    int m;
    cin>>m;
    int x[m],y[m];
    int ans=0;
    for(int i=0;i<m;i++)
        cin>>x[i]>>y[i];
    for(int mask=0;mask<(1<<m);mask++)
    {
        int z=0;memset(cnt,0,sizeof(cnt));
        for(int i=0;i<m;i++)
        {
            if(mask&(1<<i))
            {
                z++;
                cnt[x[i]]++;
                cnt[y[i]]++;
                cnt[lc[x[i]][y[i]]]-=2;
               // cout<<x[i]<<" "<<y[i]<<endl;
            }
        }
        dfs1(1,0);
        int pr=n-1;
        for(int i=1;i<=n;i++)
            if(cnt[i]>0)
                pr--;
        if(z%2)
        {
            ans=ans-(1LL<<pr);
        }
        else
        {
            ans=ans+(1LL<<pr);
        }
    }
    cout<<ans<<endl;
    
}
int32_t main()
{
    IOS;
    int t;
    t=1;
    //  cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256