2275: A Big Forest

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:3 解决:3

题目描述

XiaoMing recently plays the World of Warcraft game, you know, World of the Warcraft map is very big and now XiaoMing falls into a large forest, assuming that the forest is a rectangle with N by M. there are only some trees in the forest that he cannot go through and he can't be out of the boundary of the forest. He would like to know that could he find the exit of the forest.

输入

The first line of input is T,( 1 <= T <= 50) the number of test cases. Each test case starts with three integers N, M, K(1<=N,M<=1000000, 0<=K<=200) ,which means that the sizes of the maze and the number of trees. Then follow K lines, each line contains two integers Xi, Yi(0<=Xi< N,0<=Yi<M) denoting the position of each tree. The Last line consists of four integers Sx, Sy, Ex, Ey (0<=Sx, Ex<N, 0<=Sy, Ey<M) denoting the position of XiaoMing's starting place and the position of the exit.

Note: The starting place and the exit will not have trees there.

输出

For every test case, you should output "Case k: " first in a single line, where k indicates the case number and starts at 1. Then print "YES" if XiaoMing can reach the exit, or print "NO" if he cannot.

样例输入 复制

2
6 6 5
0 0
0 1
1 1
2 0
2 1
1 0 5 5
6 6 4
0 0
0 1
2 0
2 1
1 0 5 5

样例输出 复制

Case 1: NO
Case 2: YES