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 intersections and highways, going all over the place and taking up lots of valuable building land. However, that is not your concern right now, BMP and MSA has bribed you with DMOJ points to help them get home safely!
In an attempt to stop them, security has released their newest invention: the Giant Ant Dispenser on intersections. The dispenser will constantly dispense an infinite number of ants which will eat BMP and MSA in an instant. Obviously, BMP and MSA has instructed you to avoid all routes where you will run into the giant ants. Luckily, the giant ants will only travel along roads, but since there are an infinite number of ants, they will split off in all directions (but only along roads of course). In addition, ants are quite slow, as they only travel at 0.25 roads per second (meaning that every 4th turn, they will fully move along 1 road) while BMP's car travels at 1 road/second.
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 and .
The next lines will have and representing a road between the 2 intersections.
The next line will have .
The next lines will contain , showing that intersection has a giant ant dispenser.
Output Specification
Output a single integer, the length of the shortest path for BMP and MSA to get home from to while avoiding the ants.
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 to .
However, after 4 turns the ants spread from intersection to 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