Getting Wrong answer for second test case

link for the above code

if p==1 then day 366