UVA178 Shuffling Patience

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=114 [PDF](https://uva.onlinejudge.org/external/1/p178.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA178/9760948a9e982d8be955fbb1cf841b85fc652c8b.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA178/6f40c8a6eee809d4a4174c4b415a5cf0acb3af68.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA178/2fa51b816f2a6b24b315a91231792e19ffbc03bd.png)