Can anyone help me to find my mistake in this.. showing WA.. https://www.codechef.com/viewsolution/21711021

https://www.codechef.com/viewsolution/21711021

Try out the test case

monday tuesday 9 9

I think your output will be impossible but output should be 9

Refer editorial for more details