// Slower C++ solution:
#include<bits/stdc++.h>



#define fi first

#define se second

#define ll long long

#define pb push_back

#define mp make_pair

#define mt make_tuple



using namespace std;



vector<int> graf[100];

map<pair<int, int>, int> grana;

vector<int> svaki[100][100];

bool veza[100];

pair<int, int> niz[30];

bool mark[60];

int n;

ll res = 0;



ll stepen(ll a, int k)

{

    if(k == 0) return 1;

    ll rez = stepen(a, k/2);

    rez *= rez;

    if(k % 2 == 1) rez *= a;

    return rez;

}



bool dfs(int x, int goal, int pret, int ind1, int ind2)

{

    //if(!prvi) cout << x << " * ";

    mark[x] = true;

    if(x == goal)

    {

        mark[x] = false;

        if(pret != 0 && pret != x) svaki[ind1][ind2].pb(grana[mp(min(x, pret), max(x, pret))]);

        return true;

    }

    for(int i = 0; i < graf[x].size(); i++)

    {

        int cvor = graf[x][i];

        if(!mark[cvor])

            if(dfs(cvor, goal, x, ind1, ind2))

            {

                mark[x] = false;

                if(pret != 0 && pret != x) svaki[ind1][ind2].pb(grana[mp(min(x, pret), max(x, pret))]);

                return true;

            }

    }

    mark[x] = false;

    return false;

}





void perm(int ind, int l, int cnt, string s, bool add)

{

    if(ind == l)

    {

        if(cnt != 0) {cout << "kurac"; return;}

        for(int i = 0; i < l; i++)

            if(s[i] == '1')

            {

                int a = min(niz[i].fi,niz[i].se);

                int b = max(niz[i].fi,niz[i].se);

                for(int i = 0; i < svaki[a][b].size(); i++) veza[svaki[a][b][i]] = true;

            }

        int broj = 0;

        for(int i = 1; i <= n; i++) if(veza[i]) broj++;

        //int broj = veza.size();

        //cout << s << " " << broj << "\n";

        broj = n - 1 - broj;

        ll komb = stepen(2, broj);



        if(add) res += komb;

        else res -= komb;

        memset(mark, false, sizeof(mark));

        memset(veza, false, sizeof(veza));

        return;

    }



    if(l - cnt > ind) perm(ind + 1, l, cnt, s + "0", add);

    if(cnt > 0) perm(ind + 1, l, cnt-1, s + "1", add);

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);





    cin >> n;

    for(int i = 0; i < n - 1; i++)

    {

        int a, b;

        cin >> a >> b;

        graf[a].pb(b);

        graf[b].pb(a);

        grana[mp(min(a,b), max(a,b))] = i+1;

    }

    int m;

    cin >> m;

    for(int i = 0; i < m; i++)

        cin >> niz[i].fi >> niz[i].se;



    for(int i = 0; i < m; i++)

    {

        int a = min(niz[i].fi,niz[i].se);

        int b = max(niz[i].fi,niz[i].se);

        dfs(niz[i].fi, niz[i].se, 0, a, b);

    }



    for(int i = 1; i <= m; i++)

        perm(0, m, i, "", i % 2);



    //cout << res;

    cout << stepen(2, n-1) - res;



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2616642849490014x):
#include<bits/stdc++.h>

#define ull unsigned long long

#define ll long long

#define INF 0x3f3f3f3f

using namespace std;

void close(){

       std::ios::sync_with_stdio(false);

       std::cin.tie(0);

}

int n,m,x[55];

vector<pair<int,int>> v[55];

ll dp[1<<20];

bool dfs(int a,int b,int c,int d){

	if(a==c) return 1;

	for(auto &i:v[a]){

		if(i.first!=b && dfs(i.first,a,c,d)){

			x[i.second]^=1<<d;

			return 1;

		}

	}

	return 0;

}

int main(){

	close();

	cin>>n;

	int a,b;

	for(int i=1;i<n;i++){

		

		cin>>a>>b;

		v[a].emplace_back(b,i);

		v[b].emplace_back(a,i);

	}

	cin>>m;

	for(int i=0;i<m;i++){

		cin>>a>>b;

		dfs(a,0,b,i);

	}

	dp[0]=1;

	for(int i=1;i<n;i++){

		for(int j=(1<<m)-1;j>=0;j--){

			dp[j|x[i]]+=dp[j];

		}

	}

	cout<<dp[(1<<m)-1]<<endl;

}