A cactus graph is a connected undirected graph without self-loops and multiple edges in which each edge belongs to at most one simple cycle.
Given is a cactus graph G with N vertices, numbered from 1 to N, and M edges. The i-th edge connects vertices a_i and b_i, and its cost is c_i.
Let the cost of a simple path on graph G be bitwise XOR of the costs of all the edges on that path.
Answer Q queries of the form "x_i y_i k_i}': consider the costs of all simple paths connecting vertices x_i and y_i, remove duplicate values, sort the values in ascending order, and take k_i-th element. If the number of these values is less than k_i, answer −1.
The first line of the input contains two integers N and M: the number of vertices and the number of edges in the graph (2≤N≤105, N−1≤M≤2⋅105).
Each of the next M lines describes one edge and contains three integers a_i, b_i and c_i (1≤a_i,b_i≤N, a_i=b_i, 0≤c_i<230).
Then follows a line containing an integer Q: the number of queries (1≤q≤2⋅105).
Each of the next Q lines describes one query and contains three integers x_i, y_i and k_i (1≤x_i,y_i≤N, x_i=y_i, 1≤k_i≤230).
It is guaranteed that the graph given in the input is a cactus graph.
For each query, print one integer on a separate line: the answer to that query.