/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class LcaByDoubling {
    int N;
    int logN;
    vector<vector<int>> table;
    vector<int> depths;

    // dp[i][j] = 2**j th parent node from i th node
    vector<vector<int>> dp;

    void calc_depth(int node, int par, int depth) {
        depths[node] = depth;
        dp[node][0] = par;
        for (int next : table[node]) {
            if (next == par) continue;
            calc_depth(next, node, depth + 1);
        }
    }

    void calc_dp() {
        for (int k = 1; k < logN; k++) {
            for (int i = 0; i < N; i++) {
                if (dp[i][k-1] == -1) dp[i][k] = -1;
                else dp[i][k] = dp[dp[i][k-1]][k-1];
            }
        }
    }

public:
    LcaByDoubling(const vector<vector<int>> &table, int root) : table(table) {
        N = table.size();
        logN = (sizeof(int) * 8) - __builtin_clz(N);
        depths.resize(N);
        dp.resize(N);
        for (int i = 0; i < N; i++) dp[i].resize(logN, -1);
        calc_depth(root, -1, 0);
        calc_dp();
    }

    // O(logN)
    int lca(int u, int v) {
        // Assume depths[u] <= depths[v]
        if (depths[u] > depths[v]) swap(u, v);

        // Equalize depth
        int diff = depths[v] - depths[u];
        for (int k = 0; k < logN; k++) {
            if ((diff >> k) & 1) v = dp[v][k];
        }

        if (u == v) return u;

        // Popup both nodes just below the lca
        // Wrong: for (int k = 0; k < logN; k++) { ... }
        for (int k = logN - 1; k >= 0; k--) {
            if (dp[u][k] != dp[v][k]) {
                u = dp[u][k];
                v = dp[v][k];
            }
        }

        return dp[u][0];
    }
};

int dfs(int node, int par, vector<int> &nodes, vector<vector<int>> &table) {
    int val = 0;
    for (int next : table[node]) {
        if (next == par) continue;
        val += dfs(next, node, nodes, table);
    }

    val += nodes[node];
    nodes[node] = val;
    return val;
}

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> table(N);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        table[a].push_back(b);
        table[b].push_back(a);
    }
    auto solver = new LcaByDoubling(table, 0);

    int M;
    cin >> M;
    vector<P> cons;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cons.emplace_back(a, b);
    }

    int ret = 0;

    for (int mask = 0; mask < (1 << M); mask++) {
        vector<int> nodes(N, 0);
        int cnt = 0;

        for (int i = 0; i < M; i++) {
            if ((mask >> i) & 1LL) {
                P p = cons[i];
                int a = p.first;
                int b = p.second;
                int c = solver->lca(a, b);
                nodes[a]++;
                nodes[b]++;
                nodes[c] -= 2;
                cnt++;
            }
        }

        dfs(0, -1, nodes, table);
        int empty_cnt = 0;
        for (int node : nodes) if (node > 0) empty_cnt++;

        int tmp = 1;
        for (int i = 0; i < (N-1 - empty_cnt); i++) tmp*= 2;
        if (cnt % 2 == 1) tmp *= -1;

        ret += tmp;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256