#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

//Graph in adjcency list
struct Graph{
    struct Edge{
        int from;
        int to;
        ll cost;
        int id;
        Edge(int a, ll b) : to(a), cost(b) {}
        Edge(int a, int b, ll c, int i) : from(a), to(b), cost(c), id(i) {}
    };

    int N;  //頂点数
    vector<vector<Edge>> edges;   //隣接リスト
    vector<ll> dist;   //ノードの深さ
    ll diam;            //木の直径
    vector<int> deg;    //入次数
    vector<int> cycle;  //サイクル
    vector<int> parent;

    Graph(int n) : N(n), edges(n), dist(n, INF), diam(INF), deg(n, 0), parent(n, -1) {}

    void connect(int a, int b, ll c, int id){   //辺を追加
        edges[a].emplace_back(Edge(a, b, c, id));
        deg[b]++;
    }

    bool visited(int v){
        return dist[v] < INF;
    }

    void resetDist(){
        for(int i=0; i<N; i++){
            dist[i] = INF;
        }
    }

    void calcParent(int p, int v) {
        parent[v] = p;
        for(const auto& e : edges[v]){
            if(e.to == p) continue;
            calcParent(v, e.to);
        }
    }

    int calcLCA(int a, int b) {
        set<int> st;
        while(true){
            if(a != -1){
                if(st.find(a) != st.end()){
                    return a;
                }
                st.insert(a);
                a = parent[a];
            }
            if(b != -1){
                if(st.find(b) != st.end()){
                    return b;
                }
                st.insert(b);
                b = parent[b];
            }
        }
    }

    void dfs(int p, int v, ll d){    //深さ優先探索
        if(visited(v)) return;
        dist[v] = d;

        for(const auto& e : edges[v]){
            if(e.to == p) continue;
            dfs(v, e.to, d | (1LL << e.id));
        }
    }
};

signed main(){
    int n;
    cin >> n;

    
    Graph G(n);
    REP(i, n-1){
        int a, b;
        cin >> a >> b;
        G.connect(a-1, b-1, 1, i);
        G.connect(b-1, a-1, 1, i);
    }

    G.calcParent(-1, 0);

    int m;
    cin >> m;
    
    vector<pair<int,int>> v(m);
    vector<int> lca(m);

    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[i] = make_pair(a, b);
        lca[i] = G.calcLCA(a, b);
    }

    G.dfs(-1, 0, 0);

    ll ans = 0;
    REP(bit, 1 << m){
        ll edges = 0;
        int bitcnt = __builtin_popcount(bit);

        if(bitcnt == 0) continue;

        REP(i, m){
            if((bit >> i) & 1){
                int a = v[i].first, b = v[i].second;
                edges |= (G.dist[a] ^ G.dist[lca[i]]) | (G.dist[b] ^ G.dist[lca[i]]);
            }
        }

        int edgecnt = 0;
        REP(i, n-1){
            edgecnt += (edges >> i) & 1;
        }


        if(bitcnt %2 == 1){
            ans += (1LL << (n - 1 - edgecnt));
        }else{
            ans -= (1LL << (n - 1 - edgecnt));
        }
    }

    cout << (1LL << (n - 1)) - ans << endl;
    return 0;
}


Measured memory_bytes: 256