电梯换乘 Lift Hopping

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=20&page=show_problem&problem=1742 [PDF](https://uva.onlinejudge.org/external/108/p10801.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10801/0cbb7d34f46bb4d159da36c888a3bb419e194039.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10801/92bf4bc8a3ebf220c0627fcc9dfa4255914a00ba.png)

输出格式


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

输入输出样例

输入样例 #1

2 30
10 5
0 1 3 5 7 9 11 13 15 20 99
4 13 15 19 20 25 30
2 30
10 1
0 5 10 12 14 20 25 30
2 4 6 8 10 12 14 22 25 28 29
3 50
10 50 100
0 10 30 40
0 20 30
0 20 50
1 1
2
0 2 4 6 8 10

输出样例 #1

275
285
3920
IMPOSSIBLE