#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// LCA (Lowest Common Ancenstor) {{{
// 各ノードは、0-indexed
class LCA {
 private:
    int N;  // ノード数
    const int NONE = -1;
    std::vector<std::vector<int>> G;
    int root;  // 根ノードの番号

    // parent[k][n]: ノードnから2^k回たどって到達する頂点
    std::vector<std::vector<int>> parent;
    std::vector<int> depth;  // 根からの深さ

    void dfs(int v, int p, int d) {
      parent[0][v] = p;
      depth[v] = d;
      for (auto c :  G[v]) {
        if (c == p)
          continue;
        dfs(c, v, d+1);
      }
    }

 public:
    explicit LCA(int N, int root) :
      N(N), G(N, std::vector<int>(0)),
      parent(63, std::vector<int>(N)), depth(N), root(root) {}

    void addEdge(int node1, int node2) {
      G[node1].push_back(node2);
      G[node2].push_back(node1);
    }

    void build() {
      // parent[0]とdepthを初期化
      dfs(root, NONE, 0);
      // parentを初期化
      for (int k = 0; k + 1 < 63; k++) {
        for (int v = 0; v < N; v++) {
          if (parent[k][v] == NONE)
            parent[k + 1][v] = NONE;
          else
            parent[k + 1][v] = parent[k][parent[k][v]];
        }
      }
    }

    int query(int node1, int node2) {
      if (depth[node1] > depth[node2])
        std::swap(node1, node2);
      for (int k = 0; k < 63; k++) {
        if ((depth[node2] - depth[node1]) >> k & 1) {
          node2 = parent[k][node2];
        }
      }
      if (node1 == node2)
        return node1;
      for (int k = 62; k >= 0; k--) {
        if (parent[k][node1] != parent[k][node2]) {
          node1 = parent[k][node1];
          node2 = parent[k][node2];
        }
      }
      return parent[0][node1];
    }

    int distance(int node1, int node2) {
      int lca = query(node1, node2);
      return depth[node1] + depth[node2] - 2 * depth[lca];
    }
};
// }}}

uint64_t popcnt(uint64_t n)
{
    uint64_t c = 0;
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555);
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333);
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f);
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff);
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff);
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff);
    return(c);
}

struct E {
  ll next;
  ll edgeID;
};

struct C {
  ll u;
  ll v;
  ull edge_bit;
};

ll N, M;
vector<vector<E>> edges;
vector<C> conds;
LCA lca(64, 0);
ull edge_bit[64]; // edge_bit[i]: 頂点からedge iまでに通ったエッジ一覧

// rootから頂点vへのbit一覧
void f(ll cur = 0, ull bit = 0, ll par = -1) {
  edge_bit[cur] = bit;
  // printf("cur=%d edge_bit[%d]=%d\n", cur, cur, edge_bit[cur]);
  for (auto e : edges[cur]) {
    if (e.next == par)
      continue;
    f(e.next, bit | (((ull) 1) << e.edgeID), cur);
  }
}

signed main() {
  cin >> N;
  edges.resize(N);
  rep (i, N-1) {
    ll a, b;
    cin >> a >> b;
    a--; b--;          
    edges[a].push_back({b, i});
    edges[b].push_back({a, i});
    lca.addEdge(a, b);
  }
  f();
  lca.build();
  cin >> M;
  rep (i, M) {
    ll u, v;
    cin >> u >> v;
    u--; v--;          
    // printf("u=%d v=%d\n", u, v);
    conds.push_back({u,v});
  }
  for (ll i=0; i<M; i++) {
    ll _lca = lca.query( conds[i].u, conds[i].v );
    conds[i].edge_bit = (edge_bit[ conds[i].u ] | edge_bit[ conds[i].v ]) & (~edge_bit[_lca]);
  }

  ll all = ((ull)1) << (N-1); // 全パターンは2^(N-1)個
  ll t = 0;
  for (ull bit=1; bit < ((ull)1) << M; bit++) {
    ll sign = (popcnt(bit) % 2 == 1) ? +1 : -1;
    ull white_edge_bit = 0;
    for (ll i=0; i<M; i++) {
      if ((bit & (((ull)1) << i)) == 0) {
        continue;
      }
      white_edge_bit |= conds[i].edge_bit;
    }
    ll n_pat = (((ull)1) << (N-1-popcnt(white_edge_bit))); // 2^ (N-1-popcnt(white_edge_bit))
    //cout << "condition list bit=" << bit << " sign=" << sign << " white_edge_bit=" << white_edge_bit 
    //  << " n_pat=" << n_pat << endl;
    t += sign * n_pat;
  }
  cout << (all-t) << endl;
  return 0;
}


Measured memory_bytes: 256