UVA10978 Let's Play Magic!

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21&page=show_problem&problem=1919 [PDF](https://uva.onlinejudge.org/external/109/p10978.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10978/77b1d9b31701cb2de626366506f3e7322649d837.png)

Input Format

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

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10978/136ed0815a4e3b2bd1491b7010cfbded5101a09e.png)