#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

vector<vector<ll>> g(55);
ll n, m;
map<pair<ll, ll>, ll> mp;

ll dfs(ll a, ll b, ll p = -1) {
    ll res = 0;
    for (auto u : g[a])
        if (u != p) {
            if (u == b) {
                res = 1LL << mp[{a, b}];
                return res;
            }
            res = dfs(u, b, a);
            if (res) {
                res |= 1LL << mp[{a, u}];
                break;
            }
        }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    rep(i, 1, n) {
        ll a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        mp[{a, b}] = mp[{b, a}] = i - 1;
    }
    cin >> m;
    vector<ll> y(m);
    rep(i, 0, m) {
        ll u, v;
        cin >> u >> v;
        y[i] = dfs(u, v);
    }
    ll ans = 1LL << (n - 1);
    for (ll b = 1; b < (1 << m); b++) {
        ll d = 0;
        ll c = 1;
        rep(i, 0, m) if ((b >> i) & 1) {
            c *= -1;
            d |= y[i];
        }
        ans += c * (1LL << (n - 1 - __builtin_popcountll(d)));
    }
    cout << ans << endl;
    return 0;
}
