#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX_NODE = 51;
const int MAX_CONSTRAINT = 21;

struct LCA{
private:
    int V;
    int logV;
    int root;
    vvi G;
    vvi  parent;

    void dfs(int v, int p, int d){
        parent[0][v] = p;
        depth[v] = d;
        FORE (next, G[v]) if (next != p) dfs(next, v, d+1);
    }

public:
    vi depth;

    LCA(const vvi &g) {
        G = g;
        V = g.size();
        logV = log2(V)+1;
        parent = vvi(logV, vi(V));
        depth = vi(V);
        root=0;
        dfs(root, -1, 0);

        REP (k, logV-1) REP (v, G.size()) {
            if (parent[k][v] < 0) parent[k+1][v] = -1;
            else parent[k+1][v] = parent[k][parent[k][v]];
        }
    }

    int lca(int u,int v) {
        if (depth[u] > depth[v]) swap(u, v);
        REP (k, logV) if ((depth[v]-depth[u])>>k & 1){
            v = parent[k][v];
        }
        if (u==v) return u;
        REPR (k, logV) if (parent[k][u] != parent[k][v]) {
            u = parent[k][u];
            v = parent[k][v];
        }
        return parent[0][u];
    }

    vvi getG(){
        return G;
    }
};

int N, M;
vi edges[MAX_NODE];
ii cnstr[MAX_CONSTRAINT];
ll cnstr_nodes[MAX_CONSTRAINT];
vvi tree;
vi parent;

void set_children(int node, int p) {
    parent[node] = p;
    FORE (n, edges[node]) if (n != p) {
        tree[node].push_back(n);
        set_children(n, node);
    }
}

void make_tree() {
    tree = vvi(N);
    parent = vi(N);
    set_children(0, -1);
}

void preprocess_constraint() {
    make_tree();
    LCA lca = LCA(tree);
    REP (m, M) {
        int a = cnstr[m].first, b = cnstr[m].second;
        int c = lca.lca(a, b);
        while (a != c) {
            cnstr_nodes[m] |= (1ll << a);
            a = parent[a];
        }
        while (b != c) {
            cnstr_nodes[m] |= (1ll << b);
            b = parent[b];
        }
    }
}

ll solve() {
    preprocess_constraint();
    ll ans = 0;
    REP (i, 1ll << M) {
        int x = i;
        int cnstr_idx = 0;
        int used_cnstrs = 0;
        ll used_nodes = 0;
        while (x) {
            if (x & 1) {
                used_cnstrs++;
                used_nodes |= cnstr_nodes[cnstr_idx];
            }
            x >>= 1;
            cnstr_idx++;
        }
        ll res = 1ll << (N-1-__builtin_popcountl(used_nodes));
        if (used_cnstrs & 1) ans += res;
        else ans -= res;
    }
    return abs(ans);
}

int main() {
    cin >> N;
    REP (n, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    cin >> M;
    REP (m, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cnstr[m] = make_pair(a, b);
    }

    cout << solve() << endl;
}

Measured memory_bytes: 512