using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
using static BinaryRepresentation;

public class F
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	private List<int>[] adj;
	private int[,] id;
	private LowestCommonAncestor lca;

	public void Solve()
	{
		int N = GetInt();
		adj = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
		id = new int[N, N];
		for(int i = 0; i < N - 1; i++)
		{
			int a = GetInt() - 1;
			int b = GetInt() - 1;
			adj[a].Add(b);
			adj[b].Add(a);
			id[a, b] = i;
			id[b, a] = i;
		}

		lca = new LowestCommonAncestor(N, 0, adj);

		int M = GetInt();
		long[] path = new long[M];
		for(int i = 0; i < M; i++)
		{
			int u = GetInt() - 1;
			int v = GetInt() - 1;
			int r = lca.Lca(u, v);
			calcPath(r, u, ref path[i]);
			calcPath(r, v, ref path[i]);
		}

		long cnt = 0;
		for(int s = 1; s < (1 << M); s++)
		{
			long paths = 0;
			for(int i = 0; i < M; i++)
			{
				if(contains(s, i))
					paths |= path[i];				
			}
			long sign = (popcnt(s) % 2 == 1) ? 1 : -1;
			cnt += sign * (1L << (N - (int)popcnt(paths) - 1));
		}

		WriteLine((1L << (N - 1)) - cnt);
	}

	private bool calcPath(int v, int t, ref long path)
	{
		if(v == t)
			return true;

		bool flag = false;
		foreach(int u in adj[v])
		{
			if(u == lca.Parent(v))
				continue;

			if(calcPath(u, t, ref path))
			{
				path |= (1L << id[v, u]);
				flag = true;
			}
		}
		return flag;
	}

	private bool contains(int s, int x) => ((s >> x) & 1) == 1;
}

public class LowestCommonAncestor
{
	private List<int>[] adj;
	private int V;
	private int LOG_V;
	private int[,] parent;
	private int[] depth;

	public int Parent(int v) => parent[0, v];
	public int Depth(int v) => depth[v];

	public LowestCommonAncestor(int n, int root, List<int>[] a)
	{
		adj = a;
		V = n;
		LOG_V = log(n);
		parent = new int[LOG_V, V];
		depth = new int[V];

		dfs(root, -1, 0);

		for(int k = 0; k + 1 < LOG_V; k++)
		{
			for(int v = 0; v < V; v++)
			{
				if(parent[k, v] < 0)
					parent[k + 1, v] = -1;
				else
					parent[k + 1, v] = parent[k, parent[k, v]];
			}
		}
	}

	private int log(int n)
	{
		int cnt = 0;
		while(n > 0)
		{
			cnt++;
			n /= 2;
		}
		return cnt;
	}

	private void dfs(int v, int p, int d)
	{
		parent[0, v] = p;
		depth[v] = d;
		foreach(int u in adj[v])
		{
			if(u != p)
				dfs(u, v, d + 1);
		}
	}

	public int Lca(int u, int v)
	{
		if(depth[u] > depth[v])
			swap(ref u, ref v);

		for(int k = 0; k < LOG_V; k++)
		{
			if((((depth[v] - depth[u]) >> k) & 1) == 1)
				v = parent[k, v];
		}
		if(u == v)
			return u;

		for(int k = LOG_V - 1; k >= 0; k--)
		{
			if(parent[k, u] != parent[k, v])
			{
				u = parent[k, u];
				v = parent[k, v];
			}
		}
		return parent[0, u];
	}
}

public static class BinaryRepresentation
{
	/*
	* initialize: array = { 0, 1, 2, ..., N - 1 } 
	* do { ... } while(nextPermutaion(ref array));
	*/
	private static bool nextPermutation(ref int[] array)
	{
		int len = array.Length;
		int i = len - 2;
		while((i >= 0) && (array[i] > array[i + 1]))
			i--;
		if(i < 0)
			return false;

		int pivot = array[i];
		int j = i + 1;
		while((j < len - 1) && (array[j + 1] > pivot))
			j++;
		
		int tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;
		
		Array.Reverse(array, i + 1, len - i - 1);

		return true;
	}

	/* 
	* nCk
	* initialize: comb = (1 << k) - 1
	* while(comb < (1 << n)) { ...; comb = nextCombination(comb); };
	*/
	public static int nextCombination(int comb)
	{
		int x = comb & -comb;
		int y = comb + x;
		return (((comb & ~y) /x) >> 1) | y;
	}

	public static int popcnt(int v) {
		v = v - ((v >> 1) & 0x55555555);
		v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
		return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
	}

	public static long popcnt(long v) {
		v = v - ((v >> 1) & 0x5555555555555555);
		v = (v & 0x3333333333333333) + ((v >> 2) & 0x3333333333333333);
		return ((v + (v >> 4) & 0xF0F0F0F0F0F0F0F) * 0x101010101010101) >> 56;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13508