Why is this code not working? ACM14KG3

This is the link to my submission :CodeChef: Practical coding for everyone
Problem: Discount on crackers | CodeChef
Can anyone pls tell me why this is not working?

Try this test case.

Input

1
ab
bc
3
a->b
b->a
a->c

Expected Output

YES

Your Output

NO

huh, we can change more than once for the same character, my interpretation of the question was wrong , sorry!