#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

struct Edge {
    long long to, id;
};
using Graph = vector<vector<Edge>>;

/* LCA(G, root): 木 G に対する根を root として Lowest Common Ancestor を求める構造体
    query(u,v): u と v の LCA を求める。計算量 O(logn)
    前処理: O(nlogn)時間, O(nlogn)空間
*/
struct LCA {
    vector<vector<int>> parent;  // parent[k][u]:= u の 2^k 先の親
    vector<int> depth;           // root からの深さ
    LCA(const Graph &G, int root = 0) { init(G, root); }
    void init(const Graph &G, int root = 0) {
        int V = G.size();
        int K = 1;
        while ((1 << K) < V) K++;
        parent.assign(K, vector<int>(V, -1));
        depth.assign(V, -1);
        dfs(G, root, -1, 0);  // initialization of parent[0] & depth
        // initialization of parent
        for (int k = 0; k + 1 < K; k++) {
            for (int v = 0; v < V; v++) {
                if (parent[k][v] < 0) {
                    parent[k + 1][v] = -1;
                } else {
                    parent[k + 1][v] = parent[k][parent[k][v]];
                }
            }
        }
    }
    void dfs(const Graph &G, int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (auto e : G[v]) {
            if (e.to != p) dfs(G, e.to, v, d + 1);
        }
    }
    int query(int u, int v) {
        if (depth[u] > depth[v]) swap(u, v);
        int K = parent.size();
        for (int k = 0; k < K; k++) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = parent[k][v];
            }
        }
        if (u == v) return u;
        for (int k = K - 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 depth[u] + depth[v] - 2 * depth[query(u, v)]; }
};

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    Graph G(N);
    vector<pair<int, int>> edges;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
        edges.push_back({a, b});
    }

    LCA lca(G, 0);

    int M;
    cin >> M;
    vector<ll> cons(M);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        rep(j, N - 1) {
            int a = edges[j].first;
            int b = edges[j].second;
            if ((lca.dist(u, a) + lca.dist(a, v) == lca.dist(u, v))
                && (lca.dist(u, b) + lca.dist(b, v) == lca.dist(u, v))) {
                cons[i] |= 1LL << j;
            }
        }
    }

    ll ans = 0;
    rep(bit, 1LL << M) {
        ll eset = 0;
        rep(i, M) {
            if (bit & (1LL << i)) {
                eset |= cons[i];
            }
        }
        int white = __builtin_popcountll(eset);
        ll num = 1LL << (N - 1 - white);
        // cout << "bit:" << bit << " white:" << white << " num:" << num << endl;
        if (__builtin_popcountll(bit) % 2 == 0) {
            ans += num;
        } else {
            ans -= num;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256