#include <bits/stdc++.h>
template <class T> inline bool chmin(T &x, const T &y) { return x > y ? x = y, true : false; }
template <class T> inline bool chmax(T &x, const T &y) { return x < y ? x = y, true : false; }
using namespace std;
using pii=pair<int,int>;

template <int mod>
class modint
{
    int val;
public:
    constexpr modint() noexcept : val{0} {}
    constexpr modint(long long x) noexcept : val((x %= mod) < 0 ? mod + x : x) {}
    constexpr long long value() const noexcept { return val; }
    constexpr modint operator++(int) noexcept { modint t = *this; return ++val, t; }
    constexpr modint operator--(int) noexcept { modint t = *this; return --val, t; }
    constexpr modint &operator++() noexcept { return ++val, *this; }
    constexpr modint &operator--() noexcept { return --val, *this; }
    constexpr modint operator-() const noexcept { return modint(-val); }
    constexpr modint &operator+=(const modint &other) noexcept { return (val += other.val) < mod ? 0 : val -= mod, *this; }
    constexpr modint &operator-=(const modint &other) noexcept { return (val += mod - other.val) < mod ? 0 : val -= mod, *this; }
    constexpr modint &operator*=(const modint &other) noexcept { return val = (long long)val * other.val % mod, *this; }
    constexpr modint &operator/=(const modint &other) noexcept { return *this *= inverse(other); }
    constexpr modint operator+(const modint &other) const noexcept { return modint(*this) += other; }
    constexpr modint operator-(const modint &other) const noexcept { return modint(*this) -= other; }
    constexpr modint operator*(const modint &other) const noexcept { return modint(*this) *= other; }
    constexpr modint operator/(const modint &other) const noexcept { return modint(*this) /= other; }
    constexpr bool operator==(const modint &other) const noexcept { return val == other.val; }
    constexpr bool operator!=(const modint &other) const noexcept { return val != other.val; }
    constexpr bool operator!() const noexcept { return !val; }
    friend constexpr modint operator+(long long x, modint y) noexcept { return modint(x) + y; }
    friend constexpr modint operator-(long long x, modint y) noexcept { return modint(x) - y; }
    friend constexpr modint operator*(long long x, modint y) noexcept { return modint(x) * y; }
    friend constexpr modint operator/(long long x, modint y) noexcept { return modint(x) / y; }
    static constexpr modint inverse(const modint &other) noexcept
    {
        assert(other != 0);
        int a{mod}, b{other.val}, u{}, v{1}, t{};
        while(b) t = a / b, a ^= b ^= (a -= t * b) ^= b, u ^= v ^= (u -= t * v) ^= v;
        return {u};
    }
    static constexpr modint pow(modint other, long long e) noexcept
    {
        if(e < 0) e = e % (mod - 1) + mod - 1;
        modint res{1};
        while(e) { if(e & 1) res *= other; other *= other, e >>= 1; }
        return res;
    }
    friend std::ostream &operator<<(std::ostream &os, const modint &other) noexcept { return os << other.val; }
    friend std::istream &operator>>(std::istream &is, modint &other) noexcept { long long val; other = {(is >> val, val)}; return is; }
}; // class modint

long long lcm(long long x,long long y) {return x/__gcd(x,y)*y;}

bool p[1<<20];
int ord[1<<20];
bool is[1<<20];

long long f[1<<20];
vector<pii> tre[50];

long long pat[50][50];
long long b[20];

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


    int n; cin>>n;
    for(int i=0;i<n-1;++i){
        int u,v; cin>>u>>v; --u,--v;
        tre[u].emplace_back(v,i);
        tre[v].emplace_back(u,i);
    }

    for(int u=0; u<n; ++u){
        queue<pii> que; que.push(pii(u,-1));
        while(!que.empty()){
            int f; int p; tie(f,p)=que.front(); que.pop();
            for(auto e:tre[f]){
                if(e.first!=p){
                    que.emplace(e.first,f);
                    pat[u][e.first]=pat[u][f]|1ll<<e.second;
                }
            }
        }
    }

    int m; cin>>m;
    for(int i=0; i<m; ++i){
        int u,v; cin>>u>>v; --u,--v;
        b[i]=pat[u][v];
        cerr<<b[i]<<"\n";
    }

    int all=(1<<m)-1;
    for(int s=0;s<=all;++s){
        for(int i=0;i<m;++i){
            if(s>>i&1){
                f[s]|=b[i];
            }
        }
        f[s]=1ll<<(n-1-__builtin_popcountll(f[s]));
        cerr<<f[s]<<endl;
    }
    for(int i=0; i<m;++i){
        for(int s=0;s<=all;++s){
            if(s>>i&1) f[s^1<<i]-=f[s];
        }
    }
    cout<<f[0]<<endl;

}


Measured memory_bytes: 10496