I was solving this question from Spoj

I tried many testcases but was not able to find my mistake

My Approach->

I have assumed all statements to be true initially. After that by DFS I found if there is a contradiction or not.
If Contradiction is found for some component of the graph, I have this time initialized nodes(statements) of this component to false.
Now again I did a DFS to see if the contradiction still exists

Here is my commented Solution->

Kindly Help…