Safe Places

题目描述

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

输入输出格式

输入格式


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

输出格式


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

输入输出样例

输入样例 #1

2
2 1 16
1 0 0 0
1 0 0 2
1 0 2 0
1 0 2 2
1 2 0 0
1 2 0 2
1 2 2 0
1 2 2 2
2 1 1 1
2 1 1 3
2 1 3 1
2 1 3 3
2 3 1 1
2 3 1 3
2 3 3 1
2 3 3 3
1 1 4
1 0 0 0
1 0 1 0
1 0 0 1
1 1 0 0

输出样例 #1

15.00000
0.16667