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 PYTHON3):

Solution:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def popcount(i):
    return bin(i).count('1')

def dfs(i, N, nodes, src, dest):
    """ DFS(木、再帰、重みなし) """

    dist = [INF] * N
    def rec(u, prev, c):
        if u == dest:
            return True
        dist[u] = c
        for v in nodes[u]:
            if v != prev:
                if rec(v, u, c+1):
                    # 目的の頂点に到達したら、それに至る辺集合をbitで持っておく
                    A[i] |= 1 << edges[(u, v)]
                    return True
        return False
    rec(src, -1, 0)

N = INT()
nodes = [[] for i in range(N)]
edges = {}
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)
    edges[(a, b)] = i
    edges[(b, a)] = i

M = INT()
# A[i] := 条件iで白くしなければいけない辺の集合
A = [0] * M
for i in range(M):
    u, v = MAP()
    u -= 1; v -= 1
    dfs(i, N, nodes, u, v)

# 全通り数から、包除原理に基づいて足し引きしていく
ans = 2 ** (N-1)
for S in range(1, 1<<M):
    # Sで表される条件の集合において、白くしなければならない辺の集合S2
    S2 = 0
    for i in range(M):
        if S & 1<<i:
            S2 |= A[i]
    # 白くしなければならない辺の数
    edgecnt = popcount(S2)
    # 今回の状態Sを作るパターンの通り数(2^白黒自由に選べる辺の数)
    cnt = 2**(N-1-edgecnt)
    if popcount(S) % 2 == 1:
        ans -= cnt
    else:
        ans += cnt
print(ans)