#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

struct Tree
{
  const static int MAX_V = 100010;
  vector<int> E[MAX_V];
  int par[MAX_V];
  vector<int> ch[MAX_V];
  int depth[MAX_V];

  void dfs(int p, int d, bool make_ch)
  {
    for (auto v : E[p])
    {
      if (par[v] != -2)
        continue;
      par[v] = p;
      depth[v] = d + 1;
      if (make_ch)
        ch[p].push_back(v);
      dfs(v, d + 1, make_ch);
    }
  }

  void make_tree(int root = 0, bool make_ch = false)
  {
    fill(par, par + MAX_V, -2);
    par[root] = -1;
    depth[root] = 0;
    dfs(root, 0, make_ch);
  }

  int par_double[MAX_V][25]; //頂点iの2^k個上の頂点
  bool calculated = false;
  void calc_double()
  {
    for (int i = 0; i < MAX_V; i++)
      par_double[i][0] = (par[i] < 0 ? -1 : par[i]);

    for (int k = 0; k < 24; k++)
    {
      for (int i = 0; i < MAX_V; i++)
      {
        if (par_double[i][k] == -1)
          par_double[i][k + 1] = -1;
        else
          par_double[i][k + 1] = par_double[par_double[i][k]][k];
      }
    }
  }

  int getLCA(int a, int b)
  {
    if (!calculated)
    {
      calc_double();
      calculated = true;
    }

    if (a == b)
      return a;

    if (depth[a] < depth[b])
      swap(a, b);

    for (int k = 24; k >= 0; k--)
    {
      if (par_double[a][k] != -1 && depth[par_double[a][k]] >= depth[b])
      {
        a = par_double[a][k];
      }
    }

    if (a == b)
      return a;

    for (int k = 24; k >= 0; k--)
    {
      if (par_double[a][k] != -1 && par_double[a][k] != par_double[b][k])
      {
        a = par_double[a][k];
        b = par_double[b][k];
      }
    }
    return par_double[a][0];
  }

  inline int length(int a, int b)
  {
    return depth[a] + depth[b] - 2 * depth[getLCA(a, b)];
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  ll n;
  cin >> n;
  Tree tr;
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tr.E[a].push_back(b);
    tr.E[b].push_back(a);
  }
  tr.make_tree();

  int m;
  cin >> m;
  int u[20], v[20];
  rep(i, m)
  {
    cin >> u[i] >> v[i];
    u[i]--, v[i]--;
  }
  ll ans = 0;
  REP(bi, 1, 1 << m)
  {
    bitset<20> bs(bi);
    bool white[50] = {};
    rep(i, m)
    {
      if (!bs[i])
        continue;
      int c = u[i];
      int lca = tr.getLCA(u[i], v[i]);
      while (c != 0 && c != lca)
      {
        white[c] = true;
        c = tr.par[c];
      }
      c = v[i];
      while (c != 0 && c != lca)
      {
        white[c] = true;
        c = tr.par[c];
      }
    }
    ll cnt = 0;
    REP(i, 1, n)
    {
      if (!white[i])
        cnt++;
    }
    int bit_cnt = 0;
    rep(i, m) bit_cnt += bs[i];
    if (bit_cnt % 2 == 0)
      ans -= 1LL << cnt;
    else
      ans += 1LL << cnt;
  }
  cout << (1LL << (n - 1)) - ans << endl;
  return 0;
}


Measured memory_bytes: 15616