UVA558 Wormholes

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=7&page=show_problem&problem=499 [PDF](https://uva.onlinejudge.org/external/5/p558.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA558/809cd6f0640b1c39542e3cb1730453de80fa4b08.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA558/eac3b6da171a0b36d1e11b2dfce19f68ac36afbd.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA558/fe82dd86c54327af57cca99b9543be92cdd32a09.png)