#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
struct edge {
  ll to, cost;
};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d[ohara], tmp, m, h, w, x, y, sum, k, q;
ll u[ohara], v[ohara];
vector<edge> g[ohara];
ll rui[ohara], pre[ohara];
int dat[100][100];
vector<ll> pa[100][10];

void dijkstra(ll s) {
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
  fill(d, d + n, LINF);
  fill(pre, pre + n, -1);
  d[s] = 0;
  que.push(pair<ll, ll>(0LL, s));
  while (!que.empty()) {
    pair<ll, ll> p = que.top();
    que.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    rep(i, Size(g[v])) {
      edge e = g[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        pre[e.to] = v;
        que.push(pair<ll, ll>(d[e.to], e.to));
      }
    }
  }
}

vector<ll> get_path(ll t) {
  vector<ll> path;
  for (; t != -1; t = pre[t]) {
    path.push_back(t);
  }
  reverse(all(path));
  return path;
}

int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  rui[0] = 1;
  rrep(i, 1, n + 10) { rui[i] = rui[i - 1] * 2; }
  rep(i, n - 1) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b({b[i], 1LL});
    g[b[i]].p_b({a[i], 1LL});
  }
  cin >> m;
  rep(i, m) {
    cin >> u[i] >> v[i];
    u[i]--;
    v[i]--;
    dijkstra(u[i]);
    vector<ll> paaa = get_path(v[i]);
    pa[i][0] = paaa;
    dijkstra(v[i]);
    paaa = get_path(u[i]);
    pa[i][1] = paaa;
  }
  ans = 1;
  rep(i, n - 1) ans *= 2;
  ll lim = (1LL << m);
  rrep(i, 1, lim) {
    ll ta = __builtin_popcount(i), ki, vi[n + 10][n + 10] = {};
    cnt = 0;
    ki = (ta % 2 == 1 ? -1 : 1);
    rep(j, m) {
      if (i & (1LL << j)) {
        // cout << 1;
        rep(k, Size(pa[j][0]) - 1) {
          ll fr = pa[j][0][k], to = pa[j][0][k + 1];
          // if (vi[fr][to]) break;
          if (!vi[fr][to]) cnt++;
          vi[fr][to] = 1;
          vi[to][fr] = 1;
        }
        rep(k, Size(pa[j][1]) - 1) {
          ll fr = pa[j][1][k], to = pa[j][1][k + 1];
          if (!vi[fr][to]) cnt++;
          vi[fr][to] = 1;
          vi[to][fr] = 1;
        }
      }
      // cout << 0;
    }
    // cout << "\n";
    cnt = (n - 1) - cnt;
    ans += ki * rui[cnt];
    // debug(i);
    // debug(ki * rui[n - cnt]);
  }
  Cout(ans);
  return 0;
}


Measured memory_bytes: 37248