#include <cstdio>
#include <cstdint>
#include <climits>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

template <typename F>
class fix_point: F {
public:
  explicit constexpr fix_point(F&& f) noexcept: F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return F::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) make_fix_point(F&& f) noexcept {
  return fix_point<F>{std::forward<F>(f)};
}

template <typename WeightType>
class weighted_edge {
public:
  using size_type = size_t;
  using weight_type = WeightType;

protected:
  size_type M_src, M_dst;
  weight_type M_weight;

public:
  weighted_edge() = default;
  weighted_edge(weighted_edge const&) = default;
  weighted_edge(weighted_edge&&) = default;

  weighted_edge(size_type s, size_type d, weight_type w):
    M_src(s), M_dst(d), M_weight(w)
  {}

  weighted_edge& operator =(weighted_edge const&) = default;
  weighted_edge& operator =(weighted_edge&&) = default;

  bool operator <(weighted_edge const& other) const {
    if (M_weight < other.M_weight) return true;
    if (other.M_weight < M_weight) return false;
    if (M_src != other.M_src) return M_src < other.M_src;
    return M_dst < other.M_dst;
  }

  size_type source() const { return M_src; }
  size_type target() const { return M_dst; }
  weight_type weight() const { return M_weight; }
};

struct directed_tag {};
struct undirected_tag {};

template <typename Edge, typename Directedness>
class adjacency_list {
public:
  using size_type = size_t;
  using edge_type = Edge;
  using weight_type = typename Edge::weight_type;
  static constexpr weight_type inf = std::numeric_limits<weight_type>::max();

private:
  std::vector<std::vector<edge_type>> M_g;

public:
  adjacency_list() = default;
  adjacency_list(adjacency_list const&) = default;
  adjacency_list(adjacency_list&&) = default;
  adjacency_list(size_type n): M_g(n) {}

  template <typename... Args>
  void emplace(size_type src, size_type dst, Args... args) {
    M_g[src].emplace_back(src, dst, args...);
    if (std::is_same<Directedness, undirected_tag>::value)
      M_g[dst].emplace_back(dst, src, args...);
  }

  void sort_by_index() {
    auto cmp = [](auto const& e1, auto const& e2) {
      return e1.target() < e2.target();
    };
    for (auto v: M_g) std::sort(v.begin(), v.end(), cmp);
  }

  size_type size() const { return M_g.size(); }
  std::vector<edge_type> const& operator [](size_type i) const { return M_g[i]; }
};

template <typename Edge, typename Directedness>
constexpr typename Edge::weight_type inf = adjacency_list<Edge, Directedness>::inf;

int popcount(intmax_t n) { return __builtin_popcountll(n); }
int parity(intmax_t n) { return __builtin_parityll(n); }

int main() {
  size_t n;
  scanf("%zu", &n);

  adjacency_list<weighted_edge<int>, undirected_tag> g(n);
  for (size_t i = 1; i < n; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);
    --a, --b;
    g.emplace(a, b, 1);
  }

  std::vector<size_t> ind(n);
  std::vector<intmax_t> path;
  make_fix_point([&](auto dfs, size_t v, size_t p) -> void {
      ind[v] = path.size();
      for (auto const& e: g[v]) {
        size_t u = e.target();
        if (u == p) continue;
        path.push_back(1_jd << (u-1));
        dfs(u, v);
        path.push_back(1_jd << (u-1));
      }
  })(0, -1);

  path.insert(path.begin(), 0);
  for (size_t i = 1; i < path.size(); ++i)
    path[i] ^= path[i-1];

  size_t m;
  scanf("%zu", &m);

  std::vector<uintmax_t> paths(m);
  for (size_t i = 0; i < m; ++i) {
    size_t u, v;
    scanf("%zu %zu", &u, &v);
    --u, --v;
    paths[i] = path[ind[v]] ^ path[ind[u]];
  }

  intmax_t res = 0;
  for (size_t i = 0; i < (1_zu << m); ++i) {
    uintmax_t mask = 0;
    for (size_t j = 0; j < m; ++j) {
      if (i >> j & 1) mask |= paths[j];
    }

    intmax_t cur = 1_jd << (n-1 - popcount(mask));
    if (parity(i) == 1) cur = -cur;
    res += cur;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 256