using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            graph = Enumerable.Repeat(0, (int)N).Select(_ => new List<(long v, long n)>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                (long a, long b) = Slice<long, long>();
                --a; --b;
                graph[a].Add((b, i));//i:枝番号
                graph[b].Add((a, i));
            }
            var M = Sarray()[0];
            var ele = new long[M];
            for (var i = 0; i < M; ++i)
            {
                (long u, long v) = Slice<long, long>();
                --u; --v;
                ele[i]=dfs(-1, u, v);//ele:(u,v)間の枝の集合
            }
            var edgeNum = N - 1;
            var ans = 0L;
            var _2Pow = new long[50];
            _2Pow[0] = 1;
            for (var i = 1; i < 50; ++i)
                _2Pow[i] = _2Pow[i - 1] * 2;
            // 包除原理
            for (var bit = 1L; bit < (1L << (int)M); ++bit)
            {
                var popcount = 0;
                var uniCnd = 0L;
                var bp = 1L;
                for (var i = 0; i < M; ++i)
                {
                    if (0 != (bit & bp))
                    {
                        ++popcount;
                        uniCnd |= ele[i];
                    }
                    bp <<= 1;
                }
                var cndEdge = 0L;//使う条件で使う枝の数
                bp = 1;
                for (var i = 0; i < N; ++i)
                {
                    if (0 != (uniCnd & bp))
                        ++cndEdge;
                    bp <<= 1;
                }
                var t = _2Pow[edgeNum - cndEdge] * (_2Pow[cndEdge] - 1);//条件外の枝は白黒フリー。条件の枝は全部白の場合を除外
                if (popcount % 2 == 1) ans += t;
                else ans -= t;
            }
            WriteLine(ans);
        }
        static List<(long v, long n)>[] graph;
        static long dfs(long p, long n,long g)
        {
            if (n == g) return 0;
            foreach (var vn in graph[n])
            {
                if (vn.v == p) continue;
                var res = dfs(n, vn.v, g);
                if (0 <= res)
                    return res |= 1L << (int)vn.n;
            }
            return -1;
        }
    }
}

Measured memory_bytes: 28500