After getting out from the Building of Secrets, BMP and MSA have uncovered the secret cheesecake formula. Unfortunately, the security at the factory is very angry with them. Wanting to avoid social interaction with the security guards, BMP and MSA must get away from the cheesecake factory and get back home safely.
The city BMP and MSA live in represents the worst urban planning you have ever seen, with
In an attempt to stop them, security has released their newest invention: the Giant Ant Dispenser on
Just in case your program can't find a safe way home for BMP and MSA because of either ants blocking their route or because there is no path that will get them home safely, they have a backup plan of sacrificing bobhob314 and begging for mercy from the guards. But only if there is no safe way home (not because they want to save bobhob314 of course, but just in case they have to sacrifice him at some later time).
Note
BMP and MSA always move immediately before the giant ants do. So if BMP and MSA are currently on an intersection that's about to be overrun by ants the next turn, they are safe as long as they're moving to a safe intersection.
However, if BMP and MSA go to an intersection that's about to be overrun by giant ants right before they arrive, they get eaten!
Additionally, ant dispensers cannot start at intersection
Input Specification
The first line will contain
The next
The next line will have
The next
Output Specification
Output a single integer, the length of the shortest path for BMP and MSA to get home from
If this is not possible, output sacrifice bobhob314
.
Sample Input 1
8 7
1 2
2 3
3 4
4 5
5 6
6 7
6 8
1
7
Sample Output 1
sacrifice bobhob314
Explanation for Sample Output 1
Assume that the orange represents the intersections where the ants are, and the green is the location of BMP and MSA's car.
Initially, there is a clear path from
However, after 4 turns the ants spread from intersection
And blocks the path.
Sample Input 2
6 5
1 2
2 3
3 4
4 6
4 5
1
5
Sample Output 2
4
Explanation for Sample Output 2
Initial setup.
After 3 turns.
However, BMP and MSA's car moves before the ants, narrowly escaping the ants and getting home just before getting eaten.
Comments
Wanting to avoid social interaction with the security guards, BMP and MSA must get away from the cheesecake factory and get back home safely.
People already KNEW the social distance back in 2015.
you bet lol
What happens if there is no way home and ants cannot get you as well
This comment is hidden due to too much negative feedback. Show it anyway.
ok u guys r right i disliked myself 2