There is an undirected weighted graph with n vertices labeled from n n and an array edges, where edges[i] = [u_i, v_i, w_i] indicates an undirected edge between vertices u_i and v_i with weight w_i.
You are also given an array query, where each query[i] = [s_i, t_i].
The cost of a walk is defined as the bitwise AND of the weights of all edges traversed along that path. A walk can visit vertices and edges multiple times.
For each query, find the minimum cost among all possible walks from vertex s_i to vertex t_i. If no walk exists between s_i and t_i, the answer is
Return an array of integers representing the answer to each query.
Constraints:
n
edges.length
edges[i].length
u_i, v_i n
u_i v_i
w_i
query.length
query[i].length
s_i, t_i n
s_i t_i
There is an undirected weighted graph with n vertices labeled from n n and an array edges, where edges[i] = [u_i, v_i, w_i] indicates an undirected edge between vertices u_i and v_i with weight w_i.
You are also given an array query, where each query[i] = [s_i, t_i].
The cost of a walk is defined as the bitwise AND of the weights of all edges traversed along that path. A walk can visit vertices and edges multiple times.
For each query, find the minimum cost among all possible walks from vertex s_i to vertex t_i. If no walk exists between s_i and t_i, the answer is
Return an array of integers representing the answer to each query.
Constraints:
n
edges.length
edges[i].length
u_i, v_i n
u_i v_i
w_i
query.length
query[i].length
s_i, t_i n
s_i t_i