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

constexpr int INF = 1e9 + 6;

template<class Monoid> struct SegmentTree {
private:
    using Func = std::function<Monoid(Monoid, Monoid)>;
    Func F;
    Monoid UNITY;
    int n;
    std::vector<Monoid> node;
public:
    SegmentTree() {}

    //m=size, f=[](M a,M b){return ;}
    // size : m
    SegmentTree(int m, const Func f, const Monoid &unity) {
        build(m, f, unity);
    }

    SegmentTree(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        build(v, f, unity);
    }

    void build(int m, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
    }

    void build(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, Monoid val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a,b)
    Monoid get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return UNITY;
        if (a <= l && r <= b) return node[k];
        Monoid vl = get(a, b, 2 * k + 1, l, (r - l) / 2 + l);
        Monoid vr = get(a, b, 2 * k + 2, (r - l) / 2 + l, r);
        return F(vl, vr);
    }

    Monoid operator[](int x)const {
        return node[n + x - 1];
    }

    int size() {
        return n;
    }

    void print() {
        for (int i = 0; i < n; i++) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};

// 最近共通祖先(EulerTour)
// verrify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_5_C
// <O(N),O(lonN)>
struct LowestCommonAncestor {
private:
    int V;
    vector<int> ord, dep, id;
    SegmentTree<pair<int, int>> st; // (value,index)
    void dfs(int u, int p, int k, const vector<vector<int>> &Tree) {
        id[u] = (int)ord.size();
        ord.push_back(u);
        dep[u] = k;
        for (auto v : Tree[u]) {
            if (v != p) {
                dfs(v, u, k + 1, Tree);
                ord.push_back(u);
            }
        }
    }

public:

    // Tree以外を与えるとバグる
    LowestCommonAncestor(const vector<vector<int>> &G, int root = 0) {
        build(G, root);
    }

    void build(const vector<vector<int>> &G, int root = 0) {
        V = G.size();
        dep.resize(V);
        id.resize(V, -1);
        ord.reserve(2 * V - 2);
        dfs(root, -1, 0, G);
        vector<pair<int, int>> stvec(2 * V - 2);
        for (int i = 0; i < 2 * V - 2; i++) {
            stvec[i].first = dep[ord[i]];
            stvec[i].second = i;
        }
        st.build(stvec, [](pair<int, int> a, pair<int, int> b) {return min(a, b); }, {INF,-1});
    }

    // u, vのlca O(logN)
    int lca(int u, int v) {
        return ord[st.get(min(id[u], id[v]), max(id[u], id[v]) + 1).second];
    }

    // u, vの距離 O(logN)
    int dist(int u, int v) {
        int lca_ = lca(u, v);
        return dep[u] + dep[v] - 2 * dep[lca_];
    }

    int depth(int v) {
        return dep[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;
    g.resize(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);
    }
    LowestCommonAncestor lca(G);
    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