using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    private int N;
    private List<Edge>[] Edges;
    private int M;
    private int[] U, V;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        Edges = new List<Edge>[N];
        for (int i = 0; i < N; i++)
        {
            Edges[i] = new List<Edge>();
        }

        for (int i = 0; i < N - 1; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            Edges[a].Add(new Edge(b, i));
            Edges[b].Add(new Edge(a, i));
        }

        M = sc.NextInt();
        U = new int[M];
        V = new int[M];
        for (int i = 0; i < M; i++)
        {
            U[i] = sc.NextInt() - 1;
            V[i] = sc.NextInt() - 1;
        }


        long[] flag = new long[M];

        for (int i = 0; i < M; i++)
        {
            Search(U[i], -1, V[i], out flag[i]);
        }

        long l = 1 << M;
        long ans = 0;
        for (int i = 0; i < l; i++)
        {
            long t = 0;
            int cnt = 0;
            for (int j = 0; j < M; j++)
            {
                if ((i & (1 << j)) == 0) continue;
                t |= flag[j];
                cnt++;
            }

            long n = 1;
            for (int j = 0; j < N - 1; j++)
            {
                if ((t & (1L << j)) == 0) n *= 2;
            }

            if (cnt % 2 == 0)
            {
                ans += n;
            }
            else
            {
                ans -= n;
            }
        }

        Console.WriteLine(ans);
    }

    bool Search(int p, int parent, int target, out long ans)
    {
        ans = -1;
        if (p == target)
        {
            ans = 0;
            return true;
        }

        foreach (Edge edge in Edges[p])
        {
            if (edge.To == parent) continue;
            long o;
            if (Search(edge.To, p, target, out o))
            {
                ans = o | (1L << edge.Num);
                return true;
            }
        }

        return false;
    }

    public static void Main(string[] args) => new Program().Solve();
}

struct Edge
{
    public int To, Num;

    public Edge(int t, int i)
    {
        To = t;
        Num = i;
    }
}


namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268