#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

struct edge {
    ll to, cost, num;
};

int V;
vector<edge> G[1000000];
ll d[1000000];

void addedge(int st, int ed, ll co, ll num) {
    edge e;
    e.to = ed;
    e.cost = co;
    e.num = num;
    G[st].push_back(e);
}

//根付き木を作る。parentVectorに親nodeの番号が入る。
//parentVector[root] = -1
vector<ll> par;
void makeRootedTree(vector<ll> &parentVector, ll root, ll size) {
    parentVector = vector<ll>(size);
    assert(root < (ll)parentVector.size());
    parentVector[root] = -1;
    queue<ll> que;
    que.push(root);
    while (!que.empty()) {
        ll node = que.front();
        que.pop();
        REP (i, 0, G[node].size()) {
            edge e = G[node][i];
            if (e.to != parentVector[node]) {
                parentVector[e.to] = node;
                que.push(e.to);
            }
        }
    }
}

ll anc[51][51];
bool bo[51][21];
plglg path[21];
vector<ll> childs[51];

//根付き木の葉から根に向かって何か処理をする
void leafToRoot(vector<ll> &parentVector, ll root) {
    queue<ll> que;
    vector<ll> used(V);
    fill(used.begin(), used.end(), 0);
    REP(i, 0, V) {
        if (i != root && G[i].size() == 1) {
            que.push(i);
            used[i] = 1;
        }
    }
    while (!que.empty()) {
        ll node = que.front();
        que.pop();

        childs[node].push_back(node);
        REP(i, 0, childs[node].size()) {
            REP(j, i, childs[node].size()) {
                ll p = childs[node][i];
                ll q = childs[node][j];
                if (anc[p][q] == -1) {
                    anc[p][q] = node;
                    anc[q][p] = node;
                }
            }
        }

        if (node == root) {
            break;
        }
        ll parent = parentVector[node];
        used[parent]++;

        REP(i, 0, childs[node].size()) {
            childs[parent].push_back(childs[node][i]);
        }

        if ((parent == root && used[parent] == (ll)G[parent].size()) ||
            (parent != root && used[parent] == (ll)G[parent].size() - 1)) {
            que.push(parent);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    V = N;
    REP(i, 0, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        addedge(a, b, 1, i);
        addedge(b, a, 1, i);
    }
    makeRootedTree(par, 0, N);
    REP(i, 0, N) {
        fill(anc[i], anc[i] + N, -1);
    }
    leafToRoot(par, 0);
    // REP(i, 0, N) {
    //     REP(j, 0, N) {
    //         cout << i << " " << j << " " << anc[i][j] << endl;
    //     }
    // }
    ll M;
    cin >> M;
    REP(i, 0, M) {
        fill(bo[i], bo[i] + M, false);
    }
    REP(i, 0, M) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        path[i] = plglg(u, v);
        ll ancnode = anc[u][v];
        while(u != ancnode) {
            REP(j, 0, G[u].size()) {
                edge e = G[u][j];
                if (e.to == par[u]) {
                    bo[e.num][i] = true;
                    break;
                }
            }
            u = par[u];
        }
        while(v != ancnode) {
            REP(j, 0, G[v].size()) {
                edge e = G[v][j];
                if (e.to == par[v]) {
                    bo[e.num][i] = true;
                    break;
                }
            }
            v = par[v];
        }
    }
    ll ans = 0;
    REP(bit, 0, ((ll)1 << M)) {
        ll num = 0;
        REP(i, 0, N - 1) {
            bool white = false;
            REP(j, 0, M) {
                if (bit & ((ll)1 << j)) {
                    if (bo[i][j]) {
                        white = true;
                    }
                }
            }
            if (!white) {
                num++;
            }
        }
        ll tmp = ((ll)1 << num);
        ll bitnum = 0;
        REP(i, 0, M) {
            if (bit & ((ll)1 << i)) {
                bitnum++;
            }
        }
        if (bitnum % 2 == 0) {
            ans += tmp;
        } else {
            ans -= tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 25472