#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct Node{
    int id, v;
    bool done = false;
    Node(int id, int v=0): id(id), v(v) {}
    Node(): id(0), v(0) {}

    bool operator==(const Node& x) { return v == x.v; }
    bool operator!=(const Node& x) { return v != x.v; }
    bool operator<(const Node& x) { return v < x.v; }
    bool operator>(const Node& x) { return v > x.v; }
    bool operator<=(const Node& x) { return v <= x.v; }
    bool operator>=(const Node& x) { return v >= x.v; }

    bool comp(Node node){
        return v < node.v;
    }
};

struct Edge{
    Node from, to;
    int cost, id;
    Edge(Node from, Node to, int cost=1, int id=-1): from(from), to(to), cost(cost), id(id) {}

    bool comp(Edge e){
        return cost < e.cost;
    }
};

struct Graph{
    int N, M;
    vector<vector<Edge>> adj;

    Graph(int N, int M): N(N), M(M) {
        adj.resize(N, vector<Edge>());
    }

    Graph() {}

    void add_edge(int i, int j, int cost=1, int id=-1){
        Node from(i), to(j);
        Edge e(from, to, cost, id);
        adj[i].emplace_back(e);
    }

    vector<Edge> get_adj(Node node){
        return adj[node.id];
    }

    void assign(int n, int m){
        N = n; M = m;
        adj.assign(N, vector<Edge>());
    }
};

Graph G;
vector<int> done;

bool dfs(Node v, int p, Node target, bitset<50> &b){
    if(done[v.id]) return false;
    done[v.id] = 1;

    if(v.id == target.id){
        if(p != -1) b[p] = 1;
        return true;
    }

    for(Edge e : G.get_adj(v)){
        if(dfs(e.to, e.id, target, b)){
            if(p != -1) b[p] = 1;
            return true;
        }
    }

    return false;
}

int main(void){
    ll N; cin >> N;
    G.assign(N,N-1);
    REP(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G.add_edge(a,b,1,i);
        G.add_edge(b,a,1,i);
    }

    ll M; cin >> M;
    vector<bitset<50>> path(M);
    REP(i,M){
        int u,v; cin >> u >> v;
        u--; v--;
        done.assign(N,0);
        dfs(Node(u), -1, Node(v), path[i]);
    }

    ll ans = 0;
    for(ll i=0; i<(1LL<<M); i++){
        bitset<50> c;
        ll n = 0;
        REP(j,M) if(i>>j & 1){ c |= path[j]; n++;}
        if(n%2 == 0) ans += 1LL<<(N-1-(ll)c.count());
        else ans -= 1LL<<(N-1-(ll)c.count());
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256