Online solution in O(M*logM+(N+Q)*logN)
We compute the minimum spanning trees (there can be multiple ones, we are not guaranteed that the graph is connected) using Kruskal\'s Algorithm.  O(M*logM) fro
We compute the minimum spanning trees (there can be multiple ones, we are not guaranteed that the graph is connected) using Kruskal\'s Algorithm.  ``O(M*logM)`` from sorting.\nWe then build Binary Lifting data structure on the trees. ``O(N*logN)``.\nFor each query we get LCA of the 2 nodes ``x`` and ``y`` using Binary Lifting data structure and we also get max edge cost on the path from ``x`` to LCA and from ``y`` to LCA. If the maximum edge cost on the path is less than the limit, the answer to query is true. ``O(logN)`` per query, ``O(Q*logN)`` total.\nAdding up the complexities ``O(M*logM+(Q+N)*logN)``.
[]