#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int countbits(long long bits)
{
    bits = (bits & 0x5555555555555555) + ((bits >> 1) & 0x5555555555555555);
    bits = (bits & 0x3333333333333333) + ((bits >> 2) & 0x3333333333333333);
    bits = (bits & 0x0f0f0f0f0f0f0f0f) + ((bits >> 4) & 0x0f0f0f0f0f0f0f0f);
    bits = (bits & 0x00ff00ff00ff00ff) + ((bits >> 8) & 0x00ff00ff00ff00ff);
    bits = (bits & 0x0000ffff0000ffff) + ((bits >>16) & 0x0000ffff0000ffff);
    return (bits & 0x00000000ffffffff) + ((bits >>32) & 0x00000000ffffffff);
}

bool dfs(VVI &es, VI &vs, int pos, int t, int par = -1) {
    if (pos == t) {
        vs.push_back(pos);
        return true;
    }
    vs.push_back(pos);
    for (int dst: es[pos]) {
        if (dst == par) continue;
        if (dfs(es,vs,dst,t,pos)) return true;
    }
    vs.pop_back();
    return false;
}

void solve() {
    int n,m,a,b;
    cin >> n;
    VVI es(n);
    map<PII,int> ma;
    REP(i,0,n-1) {
        cin >> a >> b;
        --a; --b;
        es[a].push_back(b);
        es[b].push_back(a);
        if (a > b) swap(a,b);
        ma[MP(a,b)] = i;
        ma[MP(b,a)] = i;
    }

    cin >> m;
    VVI as(m);
    REP(i,0,m) {
        cin >> a >> b;
        --a; --b;
        dfs(es,as[i],a,b);
    }
    VLL bs(m);
    REP(i,0,m) {
        REP(j,1,as[i].size()) {
            int l = as[i][j-1], r = as[i][j];
            if (l > r) swap(l,r);
            bs[i] |= (1LL<<(ma[MP(l,r)]));
        }
    }
    LL ans = 0;
    VLL ps(n+1,1);
    REP(i,1,n+1) ps[i] = ps[i-1] * 2;
    REP(p,0,1<<m) {
        int b = countbits(p);
        int pm = (b % 2 == 0) ? 1 : -1;
        LL bp = 0;
        REP(i,0,m) {
            if (!(p & (1<<i))) continue;
            bp |= bs[i];
        }
        LL cnt = ps[n-1-countbits(bp)];
        ans += cnt * pm;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}


Measured memory_bytes: 3584