#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<vector<int> > G;
vector<vector<int> > edgeName;
vector<pii> P;

void input(){
    fast_io();
    cin >> N;
    G.resize(N);
    edgeName.assign(N,vector<int>(N,-1));
    for (int i = 0; i < N-1; i++)
    {
        int u,v; cin >> u >> v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
        edgeName[u][v] = i;
        edgeName[v][u] = i;
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        int u,v; cin >> u >> v;
        u--,v--;
        P.emplace_back(u,v);
    }
}

vector<int> bfs(int s, int t){
    queue<int> q;
    vector<bool> seen(N,false);
    vector<int> prev(N,-1);
    q.push(s);
    seen[s] = true;
    prev[s] = s;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        // if(u==t) break;要らない.
        for(int v:G[u]){
            if(seen[v]) continue;
            seen[v] = true;
            prev[v] = u;
            q.push(v);
        }
    }
    vector<int> path;
    int x = t;
    path.push_back(x);
    while(x!=s){
        x = prev[x];
        path.push_back(x);
    }
    return path;
}

ll bit_path(vector<int> path){
    ll ret = 0LL;
    int n = path.size();
    for (int i = 0; i < n-1; i++)
    {
        int u = path[i];
        int v = path[i+1];
        int e = edgeName[u][v];
        if(e==-1) continue;
        ret |= (1LL<<e);
    }
    return ret;
}

int solve(){
    // 制約がどの辺を使っているか調査する。
    vector<ll> bitPath(M,0LL);
    for (int i = 0; i < M; i++)
    {
        bitPath[i] = bit_path(bfs(P[i].first, P[i].second));
    }
    ll ans = 0LL;
    for (ll bit = 0; bit < (1<<M); bit++)
    {
        // 使う制約の個数:k
        int k = __builtin_popcountl(bit);
        // 使う辺(白く塗る辺)の集合S.bit->Sの変換.
        ll S = 0LL;
        for (int i = 0; i < M; i++)
        {
            if(bit & (1LL<<i)){
                S |= bitPath[i];
            }
        }
        // 使う辺(白く塗る辺)の数:d
        int d = __builtin_popcountl(S);
        ll res = N-1-d;
        int sign = (k%2)?-1:1;
        if(sign==1) ans += 1LL<<res;
        else ans -= 1LL<<res;
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256