The residents of DD Planet travel to a hospital for a regular checkup.
DD Planet has N houses (numbered 1,2,…,N) and M hospitals (numbered N+1,N+2,…,N+M). A deep river separates the area holding the houses from the area holding the hospitals. Crossing the river is possible only over a bridge. There are B bridges (numbered N+M+1,N+M+2,…,N+M+B), and crossing any bridge takes 0 seconds.
DD Planet also has K roads that join houses, hospitals, and bridges. A road between two bridges is allowed. Because the deep river runs between the two areas, no road joins a house directly to a hospital.
Answer Q questions.
- What is the minimum time for a resident of house Si to reach hospital Ei?