Destiny

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Given a tree T=(V,E)T = (V,E) (VV is the set of vertices and EE is the set of edges) and a set of pairs of vertices QV×VQ \subset V \times V satisfying for all (u,v)Q(u,v) \in Quvu \ne v and uu is an ancestor of vv on tree TT, you are supposed to compute how many functions f:E0,1f: E \to \\{0, 1\\} (i.e. for each edge eEe \in E, the value of f(e)f(e) would be either 00 or 11) satisfies the condition for any (u,v)Q(u,v) \in Q there exists an edge ee on the path from uu to vv such that f(e)=1f(e) = 1. Output the answer modulo 998,244,353998\\,244\\,353.

입력

The first line contains an input nn denoting the number of vertices in tree TT. The nodes are numbered from 1 to nn and the root node is node 1. In the following n1n-1 lines, each line contains two integers separated by a space x_i,y_ix\_i, y\_i such that 1x_i,y_in1 \le x\_i,y\_i \le n denoting there exists an edge on the tree between node x_ix\_i and y_iy\_i. There are no guarantees for the direction of the edge. The following line contains an integer mm denoting the size of QQ. In the following mm lines, each line contains two integers separated by a space u_i,v_iu\_i,v\_i denoting (u_i,v_i)Q(u\_i,v\_i) \in Q. There may be duplication, or in other words, there might exist some iji \ne j such that u_i=u_ju\_i = u\_j and v_i=v_jv\_i = v\_j.

출력

The output contains only an integer denoting the number of functions ff satisfying the condition above.

제한

For all test cases, n5×105n \le 5 \times 10^5m5×105m \le 5 \times 10^5. The input forms a tree, where for all 1im1 \le i \le mu_iu\_i is the ancestor of v_iv\_i.