Triangular Cactus Paths

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

문제

You are given a simple connected undirected graph that is a cactus: each edge lies on at most one simple cycle. This cactus is triangular: the length of any simple cycle is at most 33.

Answer the queries. In each query, you are given two vertices ss and ff, and an integer kk. Find the number of simple paths between vertices ss and ff with length exactly kk. You should find this number modulo 998,244,353998\\,244\\,353.

The path is simple if all its vertices are different, the length of the path is equal to the number of edges on the path.

입력

The first line contains two integers nn, mm (2n21052 \leq n \leq 2 \cdot 10^5, n1m3(n1)2n - 1 \leq m \leq \frac{3(n-1)}{2}) --- the number of vertices and edges in the graph.

Each of the next mm lines contains two integers uu, vv (1u,vn1 \leq u, v \leq n, uvu \neq v), meaning that there is an undirected edge (u,v)(u, v) in the graph. All edges are different. It is guaranteed that the graph is a connected triangular cactus.

The next line contains a single integer qq (1q21051 \leq q \leq 2 \cdot 10^5) --- the number of queries.

Each of the next qq lines contains three integers ss, ff, kk (1s,fn1 \leq s, f \leq n, 0k<n0 \leq k < n) --- the description of a query.

출력

Print qq integers --- the answers to the queries.