#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
using namespace std;


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


using pint = pair<int,int>;
using Graph = vector<vector<int>>;

struct LCA {
    vector<vector<int> > parent; // parent[d][v] := 2^d-th parent of v
    vector<int> depth;
    LCA() { }
    LCA(const Graph &G, int r = 0) { init(G, r); }
    void init(const Graph &G, int r = 0) {
        int V = (int)G.size();
        int h = 1;
        while ((1<<h) < V) ++h;
        parent.assign(h, vector<int>(V, -1));
        depth.assign(V, -1);
        dfs(G, r, -1, 0);
        for (int i = 0; i+1 < (int)parent.size(); ++i)
            for (int v = 0; v < V; ++v)
                if (parent[i][v] != -1)
                    parent[i+1][v] = parent[i][parent[i][v]];
    }
    void dfs(const Graph &G, int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (auto e : G[v]) if (e != p) dfs(G, e, v, d+1);
    }
    int get(int u, int v) {
        if (depth[u] > depth[v]) swap(u, v);
        for (int i = 0; i < (int)parent.size(); ++i)
            if ( (depth[v] - depth[u]) & (1<<i) )
                v = parent[i][v];
        if (u == v) return u;
        for (int i = (int)parent.size()-1; i >= 0; --i) {
            if (parent[i][u] != parent[i][v]) {
                u = parent[i][u];
                v = parent[i][v];
            }
        }
        return parent[0][u];
    }
    int length(int u, int v) {
        int l = get(u, v);
        return depth[u] + depth[v] - depth[l] * 2;
    }
};

int N, M;
Graph G;
vector<pint> uvs;
LCA lca;

int main() {
    cin >> N;
    G.assign(N, vector<int>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> M;
    uvs.resize(M);
    for (int i = 0; i < M; ++i) {
        cin >> uvs[i].first >> uvs[i].second;
        --uvs[i].first, --uvs[i].second;
    }

    lca.init(G);
    vector<vector<int>> len(N, vector<int>(N));
    for (int u = 0; u < N; ++u) for (int v = 0; v < N; ++v) len[u][v] = lca.length(u, v);
    long long res = 0;
    for (int bit = 0; bit < (1<<M); ++bit) {
        int con = 0;
        for (int i = 0; i < M; ++i) if (bit & (1<<i)) ++con;

        int num = N-1;
        for (auto a = 0; a < N; ++a) {
            for (auto b : G[a]) {
                if (a > b) continue;
                for (int i = 0; i < M; ++i) {
                    if (!(bit & (1<<i))) continue;
                    int u = uvs[i].first, v = uvs[i].second;
                    if (len[u][v] == len[u][a] + len[v][b] + 1 ||
                        len[u][v] == len[u][b] + len[v][a] + 1) {
                        --num;
                        break;
                    }
                }
            }
        }
        //cout << bit << ": " << num << endl;
       
        long long val = 1LL<<num;

        if (con % 2 == 0) res += val;
        else res -= val;
    }
    cout << res << endl;
}


Measured memory_bytes: 256