Problem: We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?

* The i-th (1 \leq i \leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.

Constraints

* 2 \leq N \leq 50
* 1 \leq a_i,b_i \leq N
* The graph given in input is a tree.
* 1 \leq M \leq \min(20,\frac{N(N-1)}{2})
* 1 \leq u_i < v_i \leq N
* If i \not= j, either u_i \not=u_j or v_i\not=v_j
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N
a_1 b_1
:
a_{N-1} b_{N-1}
M
u_1 v_1
:
u_M v_M


Output

Print the number of ways to paint the edges that satisfy all of the M conditions.

Examples

Input

3
1 2
2 3
1
1 3


Output

3


Input

2
1 2
1
1 2


Output

1


Input

5
1 2
3 2
3 4
5 3
3
1 3
2 4
2 5


Output

9


Input

8
1 2
2 3
4 3
2 5
6 3
6 7
8 6
5
2 7
3 5
1 6
2 8
7 8


Output

62

Solution (in JAVA):

Solution:
import java.math.*;
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	ArrayList<Integer>[] g;
	int[] parent;
	int[] height;
	int[][] lca;

	void dfs(int cur, int par) {
		parent[cur] = par;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			height[dst] = height[cur] + 1;
			dfs(dst, cur);
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		lca = new int[N][N];
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < N; ++j) {
				lca[i][j] = -1;
			}
		g = new ArrayList[N];
		parent = new int[N];
		height = new int[N];
		int[] A = new int[N - 1];
		int[] B = new int[N - 1];
		Arrays.fill(parent, -1);
		for (int i = 0; i < N; ++i)
			g[i] = new ArrayList<Integer>();
		for (int i = 0; i < N - 1; ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			--a;
			--b;
			g[a].add(b);
			g[b].add(a);
			A[i] = a;
			B[i] = b;
		}
		dfs(0, -1);
		{
			for (int u = 0; u < N; ++u) {
				for (int v = 0; v < N; ++v) {
					int curu = u;
					int curv = v;
					while (curu != curv) {
						if (height[curu] < height[curv]) {
							curu ^= curv;
							curv ^= curu;
							curu ^= curv;
						}
						curu = parent[curu];
					}
					lca[u][v] = curu;
				}
			}
			for (int h = N; h >= 0; --h) {
				for (int i = 0; i < N; ++i) {
					if (height[i] == h) {
						list.add(i);
					}
				}
			}
		}
		int M = sc.nextInt();
		int[] u = new int[M];
		int[] v = new int[M];
		for (int i = 0; i < M; ++i) {
			u[i] = sc.nextInt();
			v[i] = sc.nextInt();
			--u[i];
			--v[i];
		}
		long ans = 0;
		for (int s = 0; s < (1 << M); ++s) {
			int[] w = new int[N];
			for (int shift = 0; shift < M; ++shift) {
				if ((s >> shift) % 2 == 0)
					continue;
				int common = lca[u[shift]][v[shift]];
				w[u[shift]]++;
				w[v[shift]]++;
				w[common]--;
				w[common]--;
			}
			int ng = 0;
			for(int i=0;i<list.size();++i) {
				int cur=list.get(i);
				if(cur==0)continue;
				w[parent[cur]]+=w[cur];
				if(w[cur]>0) {
					++ng;
				}
			}
			int ok=N-1-ng;
			ans += (Integer.bitCount(s) % 2 == 0 ? 1 : -1) * (1L << ok);
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}