//https://atcoder.jp/contests/abc152/tasks/abc152_f

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}

template<typename T>
struct UnionFind {
    vector<T> par;
    vector<T> rank;
    
    UnionFind(T n = 1) {
        init(n);
    }
    
    void init(T n = 1) {
        par.resize(n); rank.resize(n);
        for (T i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(T x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(T x, T y) {
        return root(x) == root(y);
    }
    
    bool merge(T x, T y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};


#define INF (ll(1e18))

class SegmentTree {
public:
    int N, n;
    vector<ll> value;
    SegmentTree(int n) {
        this->n = n;
        this->N = 1;
        while (N < n) N *= 2;
        this->value = vector<ll>(2 * N - 1, INF);
    }
    
    void update(int i, ll x) {
        i += N - 1;
        value[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            value[i] = min(value[i * 2 + 1], value[i * 2 + 2]);
        }
    }
    
    ll query(int l, int r) {
        return _query(l, r, 0, 0, N);
    }
    
    ll _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b)
            return value[k];
        else {
            ll c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(c1, c2);
        }
    }
};

int msb(ll x) {
    int n = 0;
    while (x > 0) {
        x/=2;
        n++;
    }
    return n;
}


template <ll Modulus> class modint {
public:
    ll a;

    constexpr modint(const ll x = 0) noexcept : a(x % Modulus) {}
    constexpr ll &value() noexcept { return a; }
    constexpr operator int() const { return a; }
    constexpr operator long long() const { return a; }
    constexpr const ll &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator+(const ll rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator-(const ll rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator*(const ll rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator/(const ll rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        ll exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

#define MOD (1000000007)

void dfs(vector<ll>&L, vector<ll>&P, vector<vector<ll>>&E, ll u, ll pre, ll level) {
    L[u] = level;
    P[u] = pre;
    REP(i, E[u].size()) {
        if (E[u][i] != pre) {
            dfs(L, P, E, E[u][i], u, level+1);
        }
    }
}

typedef boost::multiprecision::cpp_int mpi;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<vector<ll>> E(N+1);
    map<pair<ll,ll>, ll> n2e;
    REP(i, N-1) {
        ll a,b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
        n2e[make_pair(a, b)] = i;
        n2e[make_pair(b, a)] = i;
    }
    vector<ll> L(N+1), P(N+1);
    dfs(L, P, E, 1, 0, 0);
    
    ll M;
    cin >> M;
    
    vector<ll> p(M);
    REP(i, M) {
        ll u, v;
        cin >> u >> v;
        
        while (u != v) {
            if (L[u] > L[v]) {
                p[i] |= (1LL<<n2e[make_pair(u, P[u])]);
                u = P[u];
            } else if (L[u] < L[v]) {
                p[i] |= (1LL<<n2e[make_pair(v, P[v])]);
                v = P[v];
            } else if (u != v) {
                p[i] |= (1LL<<n2e[make_pair(u, P[u])]);
                p[i] |= (1LL<<n2e[make_pair(v, P[v])]);
                u = P[u];
                v = P[v];
            }
        }
        
    }
    
    ll ans = 1LL << (N-1);
    
    SREP(i, 1, (1LL<<M)) {
        ll s = 0;
        REP(j, M) {
            bool usej = (i >> j)&1;
            if (usej)
                s |= p[j];
        }
        if (__builtin_popcountll(i)%2 == 1) {
            ans -= (1LL << (N-1-__builtin_popcountll(s)));
        } else {
            ans += (1LL << (N-1-__builtin_popcountll(s)));
        }
        
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 256