#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 100;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

void init(int n);
void dfs_init(int idx, int par, int dep);
int LCA(int x, int y);

void dfs(int cur, int from);
LL use_edge_dfs(int cur, int rt);

vector<P> tree[SIZE];
int bit = 0;
int par[SIZE];
int parent[32][SIZE];
int depth[SIZE];
int num = 0;

void init(int n) {
    for(int i = 0; i < 32; ++i) {
        for(int j = 0; j < SIZE; ++j) {
            parent[i][j] = -1;

        }
    }

    int tmp = n;
    while(tmp > 0) {
        tmp >>= 1;
        ++bit;

    }

    dfs_init(1, -1, 0);
    for(int i = 0; i < bit; ++i) {
        for(int j = 1; j <= n; ++j) {
            if(parent[i][j] == -1) {
                parent[i + 1][j] = -1;

            } else {
                parent[i + 1][j] = parent[i][parent[i][j]];

            }
        }
    }
    return;
}

void dfs_init(int idx, int par, int dep) {
    depth[idx] = dep;
    parent[0][idx] = par;
    for(int i = 0; i < tree[idx].size(); ++i) {
        if(tree[idx][i].F != par) {
            dfs_init(tree[idx][i].F, idx, dep + 1);

        }
    }
    return;
}

int LCA(int x, int y) {
    if(depth[x] > depth[y]) {
        swap(x, y);

    }

    for(int i = bit; i >= 0; --i) {
        if(((depth[y] - depth[x]) >> i) & 1) {
            y = parent[i][y];

        }
    }
    if(x == y) {
        return x;

    }

    for(int i = bit; i >= 0; --i) {
        if(parent[i][x] != parent[i][y]) {
            x = parent[i][x];
            y = parent[i][y];

        }
    }
    return parent[0][x];
}


bool visit[SIZE];
vector<P> rev_tree[SIZE];
void dfs(int cur, int from) {
    if(visit[cur]) return;
    visit[cur] = true;
    if(from != -1) {
        rev_tree[cur].pb(MP(from, num));
        ++num;

    }

    for(int i = 0; i < tree[cur].size(); ++i) {
        dfs(tree[cur][i].F, cur);

    }

    return;
}

LL use_edge_dfs(int cur, int rt) {
    if(cur == rt) return 0;
    LL use_bit;
    use_bit = use_edge_dfs(rev_tree[cur][0].F, rt);
    use_bit |= 1ll << rev_tree[cur][0].S;
    return use_bit;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        tree[a].pb(MP(b, -1));
        tree[b].pb(MP(a, -1));
    }

    init(n);
    dfs(1, -1);
    int m;
    cin >> m;

    LL use_edge[SIZE];
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        int lc = LCA(a, b);
        use_edge[i] = use_edge_dfs(a, lc);
        use_edge[i] |= use_edge_dfs(b, lc);

    }

    LL res = 0;
    for(int i = 0; i < (1 << m); ++i) {
        LL tmp = 0;
        int bi = 0;
        int t = i;
        while(t > 0) {
            if(t & 1) tmp |= use_edge[bi];
            t >>= 1;
            bi++;

        }
        int c = __builtin_popcountll(tmp);
        if(__builtin_popcount(i) % 2 == 0) res += 1ll << (n - 1 - c);
        else res -= 1ll << (n - 1 - c);
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256