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

The solution of the problem can be found here : https://www.codechef.com/viewsolution/21704143

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