Bridge

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=978 [PDF](https://uva.onlinejudge.org/external/100/p10037.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10037/a91d7e74df008ae6c59f3cbe56d9ac8a92dbee7a.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10037/0139e4a76f2d2f09e914d3492cfe7d93e1224365.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10037/112ff21e7798aa1670d267b3ffdc7e40b27ae6bc.png)

输入输出样例

输入样例 #1

1
4
1
2
5
10

输出样例 #1

17
1 2
1
5 10
2
1 2