- Time limit: 1.00 s
- Memory limit: 512 MB
You are given an undirected graph with nodes and edges. The graph is simple and connected.
You start at a specific node, and on each turn you must move through an edge to another node.
Your task is to answer queries of the form: "is it possible to start at node and end up on node after exactly turns?"
Input
The first line contains three integers , and : the number of nodes, edges and queries. The nodes are numbered .
After this, there are lines which describe the edges. Each line contains two integers and : there is an edge between nodes and .
Finally, there are lines, each describing a query. Each line contains three integers , and .
Output
For each query, print the answer (YES
or NO
) on its own line.
Constraints
Example
Input:
4 5 6 1 2 2 3 1 3 2 4 3 4 1 2 2 1 4 1 1 4 5 2 2 1 2 2 2 3 4 8
Output:
YES NO YES NO YES YES
Explanation:
- In query 1, a possible route is .
- In query 3, a possible route is .
- In query 6, a possible route is .