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
import java.util.*;

public class Main {
    static int n;
    static List<int[]>[] to;
    static List<Integer> path;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        // ans: m個のパスが、いずれもどこかの辺が黒く塗られているパターン数
        long ans = 0;
        
        // 辺の全探索だとO(2^50)
        // -> 包除原理で分けて考える
        
        // 条件を満たさない = どの辺も白く塗る
        // -> 各「条件を満たさない」を全て満たさないならどの条件も満たすことになる
        // -> ans = 集合AにもBにもCにも...属さない集合
        // -> = 全体 - (全集合の和集合)
        // -> = 全体 - (f(A)+f(B)+...) + (f(A,B)+f(A,C)+...) - (f(A,B,C)+f(A,B,D)+...) + ... - ...
        // -> = f()の中が偶数なら足し、奇数なら引くを全てのパターンする
        
        // to: 隣接リスト(無向)
        // 辺のidも記録する
        to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            int id = i;
            to[p].add(new int[]{q, id});
            to[q].add(new int[]{p, id});
        }
        
        // bitset[i]: i番目の制約
        // ex. 1100101 -> 辺id0,2,5,6を白く塗る
        int m = sc.nextInt();
        long[] bitset = new long[m];
        for (int i = 0; i < m; i++) {
            int start = sc.nextInt() - 1;
            int end = sc.nextInt() - 1;
            
            path = new ArrayList<Integer>();
            dfs(start, end, -1);
            for (Integer id : path) {
                // (id)bit目を立てる
                bitset[i] |= 1L<<id;
            }
        }
        
        // 制約のパターン(上の集合の組み合わせ)をbit全探索
        // [00000]～[11111]
        for (int bit = 0; bit < 1<<(m); bit++) {
            // mask: どの辺を白く塗るか
            long mask = 0;
            
            // bitの各桁をなめる
            for (int d = 0; d < m; d++) {
                // 1の桁はmaskに採用
                if ((bit & (1<<d)) != 0) {
                    mask |= bitset[d];
                }
            }
            
            // count1ofmask: 白く塗る辺の数
            // count1ofbit: 制約の数
            int count1ofmask = Long.bitCount(mask);
            int count1ofbit = Integer.bitCount(bit);
            
            if (count1ofbit % 2 == 0) {
                ans += (long)Math.pow(2, (n-1) - count1ofmask);
            } else {
                ans -= (long)Math.pow(2, (n-1) - count1ofmask);
            }
            // System.out.println(count1ofmask + " " + ans);
        }
        System.out.println(ans);
    }
    
    // 最短経路を得る
    public static boolean dfs(int p, int end, int par) {
        // 終了条件
        if (p == end) {
            return true;
        }
        
        for (int[] qData : to[p]) {
            int q = qData[0];
            int id = qData[1];
            if (q == par) continue;
            
            if (dfs(q, end, p)) {
                path.add(id);
                return true;
            }
        }
        
        return false;
    }
}