UVA12845 The Jolly Friar's Puzzle

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=861&page=show_problem&problem=4710 [PDF](https://uva.onlinejudge.org/external/128/p12845.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12845/95e498e0ef902c7f51903796477d6c0922b465f0.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12845/7eb11fcedc8832ef9dff44e0fe50a2e4c007e019.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12845/13d46eb013f94710eba3ea720308f8a1571baf59.png)