Color The Graph!!!

You are given an acyclic, bidirectional graph with N nodes and M edges. The nodes are numbered from 1 to N. You are given Q queries.


This is a companion discussion topic for the original entry at https://toph.co/p/color-the-graph