using System;
using System.Collections.Generic;

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

    private long[] F;

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

        for (int i = 0; i < N - 1; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            Edges[a].Add(new E(a, b, i));
            Edges[b].Add(new E(b, 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;
        }

        // U-Vのパス 辺 jが含まれるならtrue
        F = new long[M];
        for (int i = 0; i < M; i++)
        {
            Search(U[i], -1, i);
        }

        int l = 1 << M;
        long ans = 0;
        for (long i = 0; i < l; i++)
        {
            // 1 条件を満たさない (パスの辺は全部白)
            // 0 条件を満たしても良い
            long f = 0;
            int cnt = 0;
            for (int j = 0; j < M; j++)
            {
                if (C(i, j))
                {
                    f |= F[j];
                    cnt++;
                }
            }

            // どっちもつかっていいやつの個数
            int c = 0;
            for (int j = 0; j < N - 1; j++)
            {
                if (!C(f, j))
                {
                    c++;
                }
            }

            if (cnt % 2 == 0)
            {
                ans += 1L << c;
            }
            else
            {
                ans -= 1L << c;
            }
        }

        Console.WriteLine(ans);
    }

    private bool C(long mask, int i)
    {
        return (mask & (1L << i)) > 0;
    }

    private bool Search(int i, int parent, int index)
    {
        if (i == V[index]) return true;
        foreach (E e in Edges[i])
        {
            if (e.B == parent) continue;
            if (Search(e.B, i, index))
            {
                F[index] |= 1L << e.Index;
                return true;
            }
        }

        return false;
    }

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

struct E
{
    public int A, B, Index;

    public E(int a, int b, int i)
    {
        A = a;
        B = b;
        Index = i;
    }
}

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

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

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

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13268