#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

template<typename T>
vector<vector<T>> WarshallFloyd(const vector<vector<pair<int, T>>> &g) {
  // numeric_limits がうまく使えない場合は自分で INF を定義する.
  const auto inf = numeric_limits<T>::max() / 10;
  int n = g.size();
  vector<vector<T>> dist(n, vector<T> (n, inf));
  for(int i = 0; i < n; i++) dist[i][i] = 0;

  for(int u = 0; u < n; u++) {
    for(auto e : g[u]) {
      int v = e.first;
      T cost = e.second;
      dist[u][v] = cost;
    }
  }
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);

  return dist;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  lint po[60] = {};
  po[0] = 1;
  for(int i = 1; i < 60; i++) {
    po[i] = po[i - 1] * 2;
  }

  lint n; cin >> n;
  vector<vector<pair<int, lint>>> g(n);
  lint dist[60][60];
  for(int i = 0; i < n; i++) 
    for(int j = 0; j < n; j++) dist[i][j] = INF;
  for(int i = 0; i < n; i++) dist[i][i] = 0;
  for(int i = 0; i < n - 1; i++) {
    lint a, b; cin >> a >> b;
    a--;
    b--;
    dist[a][b] = dist[b][a] = 1;
    g[a].push_back({b, 1});
    g[b].push_back({a, 1});
  }

  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
  lint m; cin >> m;
  vector<lint> u(m);
  vector<lint> v(m);
  for(int i = 0; i < m; i++) {
    cin >> u[i] >> v[i];
    u[i]--;
    v[i]--;
  }


  vector<vector<pair<int, int>>> path(m);
  for(int i = 0; i < m; i++) {
    int node = u[i];
    while(node != v[i]) {
      for(auto e : g[node]) {
        int nxt = e.first;
        // cerr << node << " " << nxt << endl;
        if(dist[node][v[i]] - 1 == dist[nxt][v[i]]) {
          int from = min(node, nxt);
          int to = max(node, nxt);
          path[i].push_back({from, to});
          node = nxt;
          break;
        }
      }
    }
  }

  lint ans = 0;
  for(lint bit = 0; bit < (1LL << m); bit++) {
    lint add = 0;
    int used[60][60] = {};
    for(int i = 0; i < m; i++) {
      if(bit & (1LL << i)) {
        for(auto ee : path[i]) used[ee.first][ee.second] = 1;
      }
    }

    
    lint dame = 0;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        dame += used[i][j];
      }
    }
    add = po[n - 1 - dame];

    if(__builtin_popcount(bit) % 2 == 0)   ans = (ans + add);
    else                                   ans = (ans - add);

  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256