why WA in RRFRNDS

link:[“http://ideone.com/hglhKR”]
This is the link of my solution
PLZ tell me what’s wrong with my code or a test case for which it i giving wrong ansl
plz help me i and my friends have tried many test cases plz help

//