Games

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

문제

You are given a tree of nn vertices. Since you feel that there is nothing to do, you want to play a game on this tree.

Before the game, you need to assign a label _u0,1,2,,m1,m\ell\_u \in \\{ 0, 1, 2, \ldots, m-1, m \\} to each vertex uu.

The game consists of m+1m+1 stages enumerated from 00 to mm. In the ii-th stage, all vertices uu that satisfy _ui\ell\_u \le i will be painted black. If at this point, for every pair of uncolored vertices xx and yy, there exists a path from xx to yy that does not go through any of the colored vertices, then the game continues. Otherwise, you will lose and the game ends immediately. You win if the game continues after all stages.

You find that your ability to win the game depends only on how you initially assign labels to the vertices on this tree. In the next qq days, you want to re-label the vertices and play the game. On the ii-th day, you initially give the vertex a_ia\_i the label b_ib\_i. Then, you want to calculate how many ways are there to assign labels to the remaining vertices that allow you to win the game. Since the number could be large, you only need to output the answer modulo 998,244,353998\\,244\\,353.

입력

The first line contains three integers nn, mm and qq (1n,q1051 \le n, q \le 10^5, 1m301 \le m \le 30).

Each of the next n1n-1 lines contains two integers xx and yy (1x,yn1 \le x,y \le n, xyx \ne y), indicating that there is an edge between vertices xx and yy. It is guaranteed that the given graph is a tree.

Each of the next qq lines contains two integers a_ia\_i and b_ib\_i (1a_in1 \le a\_i \le n, 0b_im0 \le b\_i \le m), indicating a query.

출력

For each query, output a single line containing a single integer, indicating the answer modulo 998,244,353998\\,244\\,353.