Why Wrong Ans in RRFRNDS any test case

http://ideone.com/hglhKR
link to my solution
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