The Trip, 2007

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&page=show_problem&problem=2041 [PDF](https://uva.onlinejudge.org/external/111/p11100.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11100/f3cf2299b64feb6e4865a6128dddec87a0a01ada.png)

输入输出格式

输入格式


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

输出格式


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

输入输出样例

输入样例 #1

6
1 1 2 2 2 3
0

输出样例 #1

3
1 2
1 2
3 2