UVA641 Do the Untwist

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_problem&problem=582 [PDF](https://uva.onlinejudge.org/external/6/p641.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA641/d65a4b3f8c08650ccc7de6b1dc690655d450d462.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA641/374aa3bff473608ac702741730f29d44df99ac56.png)

Output Format

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