#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// 最近共通祖先(Doubling)
// verrify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_5_C
// <O(NlogN),O(lonN)>
struct LowestCommonAncestor {
private:
    int n;
    int log;
    vector<vector<int>> parent;
    vector<int> dep;
    vector<vector<int>> G;
    //vector<ll> dis; // root からの距離
    void dfs(const vector<vector<int>> &G, int v, int p, int d) {
        parent[0][v] = p;
        dep[v] = d;
        //dis[v] = di;
        for (int to : G[v]) {
            if (to != p) dfs(G, to, v, d + 1);
            //if (e.to != p) dfs(G, e.to, v, d + 1,di + e.cost);
        }
    }
public:
    LowestCommonAncestor(int n) : n(n) {
        G.resize(n);
    }

    void add_edge(int from, int to) {
        G[from].push_back(to);
        G[to].push_back(from);
    }

    // add_edge後にする
    void build(int root = 0) {
        log = log2(n) + 1;
        parent.resize(log, vector<int>(n));
        dep.resize(n);
        //dis.resize(n);
        dfs(G, root, -1, 0);
        for (int k = 0; k + 1 < log; k++) {
            for (int v = 0; v < G.size(); v++) {
                if (parent[k][v] < 0) {
                    parent[k + 1][v] = -1;
                }
                else {
                    parent[k + 1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }

    int depth(int v) {
        return dep[v];
    }

    // O(logN)
    int lca(int u, int v) {
        if (dep[u] > dep[v]) swap(u, v);
        for (int k = 0; k < log; k++) if ((dep[v] - dep[u]) >> k & 1) v = parent[k][v];
        if (u == v) return u;
        for (int k = log - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

    int dist(int u, int v) {
        return dep[u] + dep[v] - 2 * dep[lca(u, v)];
        //return dis[u] + dis[v] - 2 * dis[lca(u, v)];
    }
};

int n;
vector<int> g;
vector<vector<int>> G;
int cnt;

int dfs(int v, int p = -1) {
    int res = 0;
    for (int u : G[v]) {
        if (u == p) continue;
        res += dfs(u, v);
    }
    res += g[v];
    if (res >= 1) {
        cnt++;
    }
    return res;
}

int bitpopcount(ll n) {
    int res = 0;
    while (n) {
        if (n & 1) res++;
        n >>= 1;
    }
    return res;
}

int main() {
    cin >> n;
    LowestCommonAncestor lca(n);
    g.resize(n);
    G.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        lca.add_edge(a, b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    lca.build();
    int m; cin >> m;
    vector<pair<int, int>> p(m);
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        p[i].first = u;
        p[i].second = v;
    }
    ll ans = 0;
    for (int i = 0; i < (1 << m); i++) {
        g.assign(n, 0);
        cnt = 0;
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) {
                g[p[j].first]++;
                g[p[j].second]++;
                g[lca.lca(p[j].first, p[j].second)] -= 2;
            }
        }
        dfs(0);
        if (bitpopcount(i) & 1) {
            ans -= pow(2, n - 1 - cnt);
        }
        else {
            ans += pow(2, n - 1 - cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256