租车 Rent a Car

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=279&page=show_problem&problem=3864 [PDF](https://uva.onlinejudge.org/external/124/p12433.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12433/644311e3d93f71ae3326aefc92b0983b1072d998.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12433/899e550d4aaf59b1d95bda44b104b1422d645413.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12433/64ec5b1ffac74211016cb176884919cd32d96dc0.png)

输入输出样例

输入样例 #1

2
3 2 1
10 20 30
40 90 15 100
1 5
3 2 1
10 20 30
40 90 15 100
2 5

输出样例 #1

Case 1: 4650
Case 2: impossible