#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<vector<int>>;
Graph g;
Vi cnt;

// LCA
// LCAを求める
// 時間計算量：
//     初期化：O(n log n)
//     lcaを求める：O(log n)
class LCA {
    using Adj = std::vector<std::vector<int>>;  // 隣接リスト

private:
    int m_num;                               // 要素数
    int m_lognum;                            // floor(log2(m_num)) + 1
    int m_root;                              // 根
    std::vector<std::vector<int>> m_parent;  // m_parent[k][i]: i番目のノードの2^k番目の親
    std::vector<int> m_depth;                // 深さ

public:
    /**
     * コンストラクタ
     */
    LCA(const Adj& g, int root) {
        init(g, root);
    }

    void init(const Adj& g, int root) {
        m_num = static_cast<int>(g.size());
        m_root = root;

        m_lognum = 1;
        while (m_num >> m_lognum) ++m_lognum;

        m_parent.assign(m_lognum, std::vector<int>(m_num, -1));
        m_depth.assign(m_num, -1);
        dfs(g, m_root, -1, 0);

        // m_parentを初期化する
        for (int k = 0; k + 1 < m_lognum; k++) {
            for (int i = 0; i < m_num; i++) {
                if (m_parent[k][i] != -1)
                    m_parent[k + 1][i] = m_parent[k][m_parent[k][i]];
            }
        }
    }

    // 初期化時にm_parent[0]やm_depthを求めるためのDFS
    void dfs(const Adj& g, int v, int p, int d) {
        m_parent[0][v] = p;
        m_depth[v] = d;
        for (const auto& to : g[v]) {
            if (to != p) dfs(g, to, v, d + 1);
        }
    }

    // u と v のLCAを返す
    int lca(int u, int v) {
        if (m_depth[u] > m_depth[v]) std::swap(u, v);

        // u と v の深さが同じになるまで親をたどる
        for (int k = 0; k < m_lognum; k++) {
            if ((m_depth[v] - m_depth[u]) >> k & 1) {
                v = m_parent[k][v];
            }
        }

        if (u == v) return u;

        // 二分探索する
        for (int k = m_lognum - 1; k >= 0; k--) {
            if (m_parent[k][u] != m_parent[k][v]) {
                u = m_parent[k][u];
                v = m_parent[k][v];
            }
        }

        return m_parent[0][u];
    }

    const std::vector<vector<int>>& parent() {
        return m_parent;
    }
};

void dfs(Vi& cnt, int v) {
    int k = 0;
    int n = (int)g.size();
    Vi parent(g.size(), -1);
    stack<int> stk;
    Vi order(n);
    stk.push(v);
    while (!stk.empty()) {
        int u = stk.top();
        stk.pop();
        order[k++] = u;
        for (const auto& to : g[u]) {
            if (to != parent[u]) {
                stk.push(to);
                parent[to] = u;
            }
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        int u = order[i];
        for (const auto& to : g[u]) {
            if (to != parent[u]) {
                cnt[u] += cnt[to];
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    g.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    LCA lca(g, 0);

    int M;
    cin >> M;
    Vi us(M), vs(M), cas(M);
    for (int i = 0; i < M; i++) {
        cin >> us[i] >> vs[i];
        --us[i], --vs[i];
        cas[i] = lca.lca(us[i], vs[i]);
    }

    ll ans = 1LL << (N - 1);
    Vi cnt(N);
    Vi order(N);
    stack<int> stk;
    for (ll mask = 1; mask < (1LL << M); mask++) {
        fill(cnt.begin(), cnt.end(), 0);

        for (int i = 0; i < M; i++) {
            if (mask & (1LL << i)) {
                ++cnt[us[i]], ++cnt[vs[i]];
                cnt[cas[i]] -= 2;
            }
        }

        int k = 0;
        stk.push(0);
        while (!stk.empty()) {
            int u = stk.top();
            stk.pop();
            order[k++] = u;
            for (const auto& to : g[u]) {
                if (to != lca.parent()[0][u]) {
                    stk.push(to);
                }
            }
        }

        for (int i = N - 1; i >= 0; i--) {
            int u = order[i];
            for (const auto& to : g[u]) {
                if (to != lca.parent()[0][u]) {
                    cnt[u] += cnt[to];
                }
            }
        }

        ll used = 0;
        for (int i = 1; i < N; i++) {
            if (cnt[i] > 0) ++used;
        }

        if (__builtin_popcountll(mask) & 1) {
            ans -= 1LL << (N - 1 - used);
        }
        else {
            ans += 1LL << (N - 1 - used);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256