// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール

// Lowest Common Ancestor 最小共通祖先
struct tree_doubling {
    
    ll N, LOG_N;
    vector<ll> depth;
    vector<vector<ll>> par;
    ll root;
    const vector<vector<ll>> &g;
    
    // g は 0-indexed の隣接リスト
    tree_doubling(const vector<vector<ll>> &_g, const ll _root = 0) : N(_g.size()), depth(N, -1), par(N), g(_g), root(_root) {
        
        // LOG_N を厳密に求める O(log N)
        N = g.size();
        for (LOG_N = 0; (1LL << LOG_N) <= N; LOG_N++);
        
        // ダブリングリストの用意 O(N)
        for (ll i = 0; i < N; i++) {
            par[i] = vector<ll>(LOG_N + 1, -1);
        }
        
        // DFS
        dfs_doubling(root);
        
    }
    
    ll lca(ll u, ll v) {
        
        if (depth[u] > depth[v]) swap(u, v);
        
        REP(k, LOG_N + 1) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = par[v][k];
            }
        }
        if (u == v) return u;
        DSRNG(k, LOG_N, 0) {
            if (par[u][k] != par[v][k]) {
                u = par[u][k];
                v = par[v][k];
            }
        }
        return par[u][0];
        
    }
    
private:
    
    void dfs_doubling(ll i, ll from = -1, ll d = 0) {
        depth[i] = d;
        // ダブリングリストの更新
        par[i][0] = from;
        for (ll k = 0; k < LOG_N; k++) {
            if (par[i][k] == -1) {
                par[i][k + 1] = -1;
            } else {
                par[i][k + 1] = par[par[i][k]][k];
            }
        }
        // DFS
        for (const ll &c : g[i]) {
            if (c != from) {
                dfs_doubling(c, i, d + 1);
            }
        }
    }
    
};

ll powll(ll a, ll n) {
    if (n == 0) {
        return 1;
    } else if (n == 1) {
        return a;
    } else {
        ll tmp = pow(a, n/2);
        tmp *= tmp;
        if (n % 2) tmp *= a;
        return tmp;
    }
}

// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<vector<ll>> g(n);
    vector<pair<ll, ll>> e(n-1);
    REP(i, n-1) {
        ll a = inp1, b = inp1;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        e[i] = make_pair(a, b);
    }

    tree_doubling td(g);
    vector<ll> par(n, -1), pe(n, -1);
    REP(i, n-1) {
        ll u, v; tie(u, v) = e[i];
        if (td.depth[u] > td.depth[v]) swap(u, v);
        par[v] = u;
        pe[v] = i;
    }

    ll m = inp1;
    vector<ll> uvmask(m, 0);
    REP(i, m) {
        ll u = inp1, v = inp1;
        u--; v--;
        ll lca = td.lca(u, v);
        ll mask = 0;
        while (u != lca) {
            mask |= 1LL << pe[u];
            u = par[u];
        }
        while (v != lca) {
            mask |= 1LL << pe[v];
            v = par[v];
        }
        uvmask[i] = mask;
    }

    vector<ll> dp(1 << m, 0);
    REP(mask, 1 << m) {
        ll uvm = 0;
        REP(i, m) if (mask >> i & 1) uvm |= uvmask[i];
        ll w = popcountll(uvm);
        dp[mask] = powll(2, n-1-w);
    }

    REP(i, m) REP(j, 1 << m) {
        if (!(j & 1 << i)) {
            dp[j] -= dp[j | 1 << i];
        }
    }
    say(dp[0]);
    
}

Measured memory_bytes: 8448