//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

class LowestCommonAncestor
{
    //2^k >= n
    int n, k;
    vector<vector<int>> g, par;
    vector<int> dis;

    inline void build()
    {
        for (int i = 0; i < n; i++)
        {
            if (dis[i] == -1)
            {
                dis[i] = 0;
                this->calc(i);
            }
        }
        this->setpar();
    }

    void calc(int v = 0, int p = -1)
    {
        this->par[0][v] = p;
        for (int nv : this->g[v])
        {
            if (nv != p)
            {
                this->dis[nv] = this->dis[v] + 1;
                this->calc(nv, v);
            }
        }
    }

    void setpar()
    {
        for (int i = 0; i < this->k; i++)
        {
            for (int v = 0; v < this->n; v++)
            {
                if (this->par[i][v] != -1)
                {
                    this->par[i + 1][v] = this->par[i][par[i][v]];
                }
            }
        }
    }

public:
    LowestCommonAncestor(int n_, vector<vector<int>> &g_) : n(n_), g(g_), dis(n, -1)
    {
        k = log2(n + 1);
        this->par.assign(k + 1, vector<int>(n, -1));
        this->build();
    }

    int get(int u, int v)
    {
        //dis[u] <= dis[v]
        if (this->dis[u] > this->dis[v])
        {
            swap(u, v);
        }
        int d = this->dis[v] - this->dis[u];
        for (int i = k; i >= 0; i--)
        {
            if (d >> i & 1)
            {
                v = this->par[i][v];
            }
        }
        if (u == v)
        {
            return v;
        }
        for (int i = k; i >= 0; i--)
        {
            if (this->par[i][u] != this->par[i][v])
            {
                u = this->par[i][u];
                v = this->par[i][v];
            }
        }
        return this->par[0][v];
    }

    inline int dist(int u, int v)
    {
        return this->dis[u] + this->dis[v] - 2 * dis[this->get(u, v)];
    }
};

//verified @ https://onlinejudge.u-aizu.ac.jp/status/users/sifi_border/submissions/1/GRL_5_C/judge/3883181/C++14
//verified @ https://atcoder.jp/contests/abc014/submissions/7617701

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m;
    cin >> n;
    yukari<int> g(n);
    akari<pair<int, int>> es(n - 1);
    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);
        es[i] = make_pair(a, b);
    }
    cin >> m;
    LowestCommonAncestor lca(n, g);
    akari<unsigned long> ms(m);
    auto check = [&](int v, int u, int a) -> bool {
        return lca.dist(u, a) + lca.dist(a, v) == lca.dist(u, v);
    };
    for (int j = 0; j < m; j++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        for (int i = 0; i < n - 1; i++)
        {
            if (check(u, v, es[i].first) && check(u, v, es[i].second))
            {
                ms[j] |= 1UL << i;
            }
        }
    }
    i64 ans = 0;
    for (int s = 0; s < 1 << m; s++)
    {
        int popcnt = __builtin_popcount(s);
        unsigned long mask = 0;
        for (int j = 0; j < m; j++)
        {
            if (s >> j & 1)
            {
                mask |= ms[j];
            }
        }
        int ecnt = __builtin_popcountl(mask);
        ans += pow(2LL, n - 1 - ecnt) * (popcnt & 1 ? -1 : 1);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 384