UVA299 Train Swapping

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=4&page=show_problem&problem=235 [PDF](https://uva.onlinejudge.org/external/2/p299.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA299/8fd8e3a323a0c798fe8ddbc666adeff6b637e87d.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA299/1d40bfea894407ca7536e52bc51338d992d9f978.png)

Output Format

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