Given a simple undirected and connected graph with $$$N$$$ nodes and $$$M$$$ edges. Also two different nodes are given $$$a$$$ and $$$b$$$. We have to answer $$$q$$$ queries. Each query contains an integer $$$v$$$(i.e. a node) from $$$1$$$ to $$$N$$$, we need to answer if we remove node $$$v$$$ and all of it's adjacent edges from the given graph, do nodes $$$a$$$ and $$$b$$$ lies in the same connected component or not? All queries are independent.
PS: This problem is not from any contest.
Any hints to solve the above problem are appreciated. Thanks.