#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

class Node {
    public:
        vector<int> children;
        vector<int> edge_value;
        int value;
        int parent;
};

class Tree {
    public:
        int root;
        int node_num;
        vector<Node> node;
        
        Tree(vector<vector<int>> hen) {
            root = 0;
            node_num = hen.size();
            node = vector<Node>(hen.size());
            
            queue<int> v;
            v.push(root);
            node[root].parent = -1;
            int edge_num = 0;
            while(!v.empty()) {
                int tyoten = v.front();
                node[tyoten].value = tyoten;
                v.pop();
                for (int i = 0; i < hen[tyoten].size(); i++) {
                    int child = hen[tyoten][i];
                    if (child != node[tyoten].parent) {
                        node[tyoten].children.push_back(child);
                        node[tyoten].edge_value.push_back(edge_num);
                        edge_num++;
                        node[child].parent = tyoten;
                        v.push(child);
                    }
                }
            }
        }
};

int lca(Tree tree, pair<int, int> uv) {
    if (uv.first == tree.root || uv.second == tree.root)
        return tree.root;
    else {
        set<int> parent_set{uv.first};
        int parent = uv.first;
        while(parent != tree.root) {
            parent = tree.node[parent].parent;
            parent_set.insert(parent);
        }
        
        parent = uv.second;
        while(!parent_set.count(parent)) {
            parent = tree.node[parent].parent;
        }
        return parent;
    }
}

/*
vector<set<pair<int, int>>> tree_edge_partial_set(Tree tree) {
    vector<set<pair<int, int>>> partial_set(tree.node_num);
    queue<Node> value;
    value.push(tree.node[tree.root]);
    queue<set<pair<int, int>>> value_set;
    value_set.push(set<pair<int, int>>({}));
    while(!value.empty()) {
        Node v = value.front();
        set<pair<int, int>> v_set = value_set.front();
        value.pop();
        value_set.pop();
        partial_set[v.value] = v_set;
        for (int i = 0; i < v.children.size(); i++) {
            value.push(tree.node[v.children[i]]);
            set<pair<int, int>> v_set_c(v_set);
            v_set_c.insert(make_pair(v.value, v.children[i]));
            value_set.push(v_set_c);
        }
    }
    
    return partial_set;
}
*/
vector<bitset<59>> tree_edge_partial_set(Tree tree) {
    vector<bitset<59>> partial_set(tree.node_num);
    queue<Node> value;
    value.push(tree.node[tree.root]);
    queue<bitset<59>> value_set;
    value_set.push(bitset<59>(0));
    while(!value.empty()) {
        Node v = value.front();
        bitset<59> v_set = value_set.front();
        value.pop();
        value_set.pop();
        partial_set[v.value] = v_set;
        for (int i = 0; i < v.children.size(); i++) {
            value.push(tree.node[v.children[i]]);
            bitset<59> v_set_c(v_set);
            v_set_c[v.edge_value[i]] = 1;
            value_set.push(v_set_c);
        }
    }
    
    return partial_set;
}

int main(void){
    int n, m;
    cin >> n;
    vector<vector<int>> hen(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        hen[a-1].push_back(b-1);
        hen[b-1].push_back(a-1);
    }
    
    cin >> m;
    vector<pair<int, int>> seyaku(m);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        seyaku[i] = make_pair(u-1, v-1);
    }
    
    Tree tree(hen);
    
    vector<int> min_parent(m);
    rep(i, m) {
        min_parent[i] = lca(tree, seyaku[i]);
        //cout << min_parent[i] << endl;
    }
    
    vector<bitset<59>> bubunwa = tree_edge_partial_set(tree);
    vector<bitset<59>> seigen(m);
    for (int i = 0; i < m; i++) {
        seigen[i] = (bubunwa[seyaku[i].first] | bubunwa[seyaku[i].second]) & ~bubunwa[min_parent[i]];
        //cout << seigen[i] << endl;
    }
    
    ll ans = 0;
    for(ll i = 1; i < pow(2, m); i++) {
        int one_cnt = 0;
        bitset<59> tyoten(0);
        for (int j = 0; j < m; j++) {
            int one_or_zero = bitset<20>(i)[j];
            one_cnt += one_or_zero;
            if (one_or_zero) {
                /*
                set<pair<int, int>> dif, uni;
                uni = set_uni(bubunwa[seyaku[j].first], bubunwa[seyaku[j].second]);
                dif = set_diff(uni, bubunwa[min_parent[j]]);
                */
                //tyoten = set_uni(tyoten, seigen[j]);
                tyoten = tyoten | seigen[j];
            }
        }
        /*
        cout << i << endl;
        for (auto x : tyoten)
            cout << x << " ";
        cout << endl;
        */
        
        ll cont = pow(2, n-1-tyoten.count());
        //cout << i << " " << one_cnt << " "<< tyoten.size() <<" " << cont << endl;
        
        if (one_cnt % 2 == 1)
            ans += cont;
        else
            ans -= cont;
    }
    
    cout << setprecision(20) << pow(2, n-1) - ans << endl;
}

Measured memory_bytes: 384