You are given a connected undirected graph containing N nodes and M edges. The task is very simple. You are provided two nodes u and v. You are required to check whether the path from u to v is unique or not. If there exists a path, you are required to determine the distance between the nodes u and v, then print −1. You must perform these operations for Q queries.
Input format
Output format
For each query, print the distance between the two nodes if there exists a unique path between the nodes in that query. Otherwise, print −1.
Constraints
2≤N≤105N−1≤M≤min(105,N∗(N−1)2)1≤u,v≤N$$1≤Q≤105
The provided graph is connected and it does not contain self-loops and multiple edges.