UVA10417 Gift Exchanging

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1358 [PDF](https://uva.onlinejudge.org/external/104/p10417.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10417/bede3c9c1647bbbbd9e07ef3daad5c04452033c3.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10417/0b67a04d5f6db6e79ea4528f7bc16328e9034e7f.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10417/62a6f110c9bd8f3ac6013e70f4a30ead8a026c1d.png)