#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector adjs(n, vector<pair<int, int>>());
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back({i, b});
        adjs[b].push_back({i, a});
    }
    int m;
    cin >> m;
    vector<pair<int, int>> restr(m);
    rep(i, m)
    {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        restr[i] = {u, v};
    }

    vector<int> depth(n, -1);
    vector<pair<int, int>> parent(n, {-1, -1});
    {
        queue<int> qu;
        qu.push(0);
        depth[0] = 0;
        while (not qu.empty())
        {
            int v = qu.front();
            qu.pop();
            for (auto [i, u] : adjs[v])
            {
                if (depth[u] == -1)
                {
                    qu.push(u);
                    depth[u] = depth[v] + 1;
                    parent[u] = {i, v};
                }
            }
        }
    }
    debug(depth, parent);

    vector path(m, 0LL); // 通る辺をbit表現
    rep(i, m)
    {
        auto [u, v] = restr[i];
        if (depth[u] > depth[v])
        {
            swap(u, v);
        }
        auto diff = depth[v] - depth[u];
        rep(j, diff)
        {
            path[i] |= (1LL << parent[v].first);
            v = parent[v].second;
        }
        while (u != v)
        {
            path[i] |= (1LL << parent[u].first);
            path[i] |= (1LL << parent[v].first);
            u = parent[u].second;
            v = parent[v].second;
        }
    }

    int128_t ans = 0;
    rep(s, 1 << m)
    {
        int p = __builtin_popcount(s);
        auto flag = 0LL;
        rep(i, m)
        {
            if ((s >> i) & 1)
            {
                flag |= path[i];
            }
        }
        ans += ((p & 1) ? -1 : 1) * (static_cast<int128_t>(1) << (n - 1 - bitset<63>(flag).count()));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676