树上的机器人规划(简单版) Planning mobile robot on Tree (EASY Version)

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=441&page=show_problem&problem=4014 [PDF](https://uva.onlinejudge.org/external/125/p12569.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12569/b909e7d373972be10c0fb90abe4cf1a83e7220fa.png)

输入输出格式

输入格式


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

输出格式


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

输入输出样例

输入样例 #1

3
4 1 1 3
2
1 2
2 3
2 4
6 2 1 4
2 3
1 2
2 3
3 4
2 5
2 6
8 3 1 5
2 3 4
1 2
2 3
3 4
4 5
1 6
1 7
2 8

输出样例 #1

Case 1: 3
2 4
1 2
2 3
Case 2: 6
2 5
3 2
2 6
1 2
2 3
3 4
Case 3: 16
1 6
2 1
1 7
6 1
1 2
2 8
3 2
2 1
1 6
4 3
3 2
2 1
8 2
2 3
3 4
4 5