this is the atcoder contest link: https://atcoder.jp/contests/abc225/tasks/abc225_d
submission link: https://atcoder.jp/contests/abc225/submissions/26955824
If anybody could help please help me out as for printing i have proceeded with naive approach and my total time complexity O(no of elements connected*No of queries) total time complexity if any one can help
pls help me out