WA for EVENT even after passing cases suggested in other answers.

The solution of the problem can be found here : CodeChef: Practical coding for everyone

I checked if for following cases :

monday tuesday 9 9

9

monday wednesday 7 10

10

Still it gives me wrong answer. What could be wrong?

try case
saturday saturday 1 10

it should return many but you code return impossible