PETERSON Cook off

Hi, I considered as two graphs one as outer and other as inner. After examining 1st two non repeating string we can determine the path. There can be only one path after that.Can someone please help me to find out where i am missing?

here is my solution link: http://www.codechef.com/viewsolution/5452717

i checked with all corner cases… Please provide the testcases used…