#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
int my_pow(int n,int k) {
    int res = 1;
    rep(i, k) res*=n;
    return res;
}
int n;
int m;
vvi G(55);
vector<bitset<55>> bt(22);
vi vec(22);
map<P,int> mp;
int _=0;
vvb bo(55,vb(55,false));
void dfs(int s) {
  for(auto p:G[s]) {
    if(mp[{min(s,p),max(s,p)}]==0) {
      mp[{min(s,p),max(s,p)}]=_;
      _++;
      dfs(p);
    }
  }
}
void BFS(int s,int g,int x) {
    queue<int> que;
    que.push(s);
    int dist[55];
    fill(dist,dist+55,inf);
    dist[s]=0;
    while(dist[g]==inf) {
        int v = que.front();que.pop();
        for(auto p:G[v]) {
            if(dist[p]!=inf) continue;
            dist[p]=dist[v]+1;
            que.push(p);
        }
    }
    int i = g;
    while(i!=s) {
        for(auto p:G[i]) {
            if(dist[p]==dist[i]-1) {
                bt[x].set(mp[{min(i,p),max(i,p)}],1);
                i=p;
                break;
            }
        }
    }
    return;
}
signed main() {
    cin >> n;
    rep(i, n-1) {
        int a,b;cin >> a >> b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
  	dfs(0);
    cin >> m;
    vector<P> v(m);
    rep(i, m) {
        cin >> v[i].first >> v[i].second;
        v[i].first--;v[i].second--;
        BFS(v[i].first,v[i].second,i);
    }
    rep(bit,(1<<m)) {
        if(bit==0)continue;
        int k = 0;
      	bitset<55> bi;
        rep(i, m) {
            if((bit>>i)&1) {
                k++;
                bi|=bt[i];
            }
        }
        vec[k-1]+=my_pow(2,n-1-bi.count());
    }
    int count = my_pow(2,n-1);
    rep(i, m) i&1?count+=vec[i]:count-=vec[i];
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3652