code link -> https://ide.codingblocks.com/s/237887
for the given code one testcase passes but other one fails
also in the given problem statement no output format is shown if cows are not able to reach in town , I considered it to be -1
as from the spoj 's website
please help