#include <bits/stdc++.h>
#define FASTIO
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();

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

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

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];
    }

    int parent(int idx, int d) { return m_parent[d][idx]; }
};

ll bpow(ll a, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
        if (n & 1) res *= a;
        a *= a;
    }
    return res;
}

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

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

    int M;
    cin >> M;
    Vi U(M), V(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        U[i] = a;
        V[i] = b;
    }

    LCA lca(g, 0);

    ll ans = 0;
    bitset<50> used;
    for (ll mask = 0; mask < (1LL << M); mask++) {
        used.reset();
        for (int i = 0; i < M; i++) {
            if ((mask >> i) & 1) {
                int lcaidx = lca.lca(U[i], V[i]);
                int a;
                a = U[i];
                while (a != lcaidx) {
                    used[a] = true;
                    a = lca.parent(a, 0);
                }
                a = V[i];
                while (a != lcaidx) {
                    used[a] = true;
                    a = lca.parent(a, 0);
                }
            }
        }

        ll num = used.count();

        ll a = __builtin_popcountll(mask);
        if (a & 1) {
            ans -= bpow(2, N - 1 - num);
        }
        else {
            ans += bpow(2, N - 1 - num);
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256