#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

class LCA {
    private:
        int K, N;
        Graph G;
        std::vector<int> dis;
        std::vector<std::vector<int>> par;
    public:
        LCA(const Graph &g) : N((int)g.size()), G(g) {
            K = 1;
            while ((1 << K) < N) ++K;
            dis.assign(N, -1);
            par.assign(K, std::vector<int>(N, -1));
        }
        void build(int root = 0) {
            dfs(root, -1, 0);
            for (int i=1; i<K; ++i) {
                for (int j=0; j<N; ++j) {
                    if (par[i-1][j] == -1) par[i][j];
                    else par[i][j] = par[i-1][par[i-1][j]];
                }
            }
        }
        void dfs(int cur, int pre, int depth) {
            dis[cur] = depth;
            par[0][cur] = pre;
            for (int nx : G[cur]) {
                if (nx != pre) dfs(nx, cur, depth+1);
            }
        }
        int query(int u, int v) {
            if (dis[u] < dis[v]) std::swap(u, v);
            int dif = dis[u] - dis[v];
            for (int i=0; i<K; ++i) {
                if (dif & (1<<i)) u = par[i][u];
            }
            if (u == v) return u;
            for (int i=K-1; i>=0; --i) {
                if (par[i][u] != par[i][v]) {
                    u = par[i][u];
                    v = par[i][v];
                }
            }
            return par[0][u];
        }
};

int dfs(int cur, int pre, const Graph &G, vector<int> &v) {
    int res = 0;
    for (int nx : G[cur]) {
        if (nx != pre) res += dfs(nx, cur, G, v);
    }
    if (v[cur] > 0) ++res;
    if (pre != -1) v[pre] += v[cur];
    return res;
}

void solve() {
    int N;
    cin >> N;
    Graph G(N);
    for (int i=0; i<N-1; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    int M;
    cin >> M;
    vector<pair<int, int>> query(M);
    for (int i=0; i<M; ++i) {
        cin >> query[i].first >> query[i].second;
        --query[i].first, --query[i].second;
    }

    LCA lca(G);
    lca.build();
    ll res = 0;
    for (int bits=0; bits<(1<<M); ++bits) {
        vector<int> v(N);
        for (int i=0; i<M; ++i) {
            if (bits & (1<<i)) {
                ++v[query[i].first];
                ++v[query[i].second];
                v[lca.query(query[i].first, query[i].second)] -= 2;
            }
        }
        int cnt = dfs(0, -1, G, v);
        if (__builtin_popcount(bits)%2 == 0) res += (1LL << (N - cnt - 1));
        else res -= (1LL << (N - cnt - 1));
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3660