CATM  The Cats and the Mouse
In a rectangular field of size n by m squares there is a mouse and two cats. The mouse is the first to make a move, then each of the cats makes a move, then again its the mouse's turn, and so on. In each move both the mouse and the cats can move exactly one square vertically or horizontally. If the mouse is standing at the edge of the field then in its next move it can jump off the field and is saved from the cats. If in the next move one of the cats moves to the field with the mouse then there is no escape for the mouse ... =(
You are to write a program which, knowing the initial positions of mouse and the two cats, will find out if there is any way for the mouse to escape from the cats, assuming of course that each cat will do its best to catch the mouse.
Input
In the first line of input two integers n and m are given, not exceeding 100, where n is the number of rows, and m  the number of columns. The second line contains a number k [k <= 10], which defines the number of test cases for the given field. In the next k lines the initial positions of the mouse and the cats are given. The position in the field is given by two numbers: the first is the number of the row, the second is the number of the column. The first two integers are the coordinates of the mouse, the next four integers are the coordinates of the cats.
Output
You must output k lines with answers for each test case. The answer is YES, if the mouse can escape or NO otherwise.
Example
Input: 5 3 3 2 2 1 1 3 3 2 3 1 3 5 2 3 2 1 2 4 3 Output: NO YES YES
Author: Filimonenkov D.O.
hide comments
yomf:
20210209 06:27:25
I like cock too Last edit: 20210209 09:38:20 

harsh_ag7654:
20200909 09:54:34
excellent question, kudos to the maker


belal_2020:
20200715 01:16:26
AC in one go but i didn't use bfs. only conditions :))


nandadeep_2001:
20200611 08:56:11
This problem is intended to do with graph traversals like bfs or dfs and not to use the straight forward method of distance finding and checking the conditions


s_tank00_:
20200608 10:44:38
accepted in 1 go ..shouldnt be on spoj ...dissapointed 

jprm2:
20190824 11:35:01
not includes bfs not at all


gaurav1614:
20190420 14:47:32
got accepted with simple implementation.but how do i solve using bfs apart from applying bfs thrice for each of the cat and mouse? 

va1ts7_100:
20190113 13:49:01
Only 4 comparisions are enough .... :) ... AC Iin one go :) 

masterassassin:
20181221 21:13:22
AC in 1 GO :)) 

s_a_k_s_h_a_m:
20180626 19:58:39
I like cock Last edit: 20210209 09:38:08 
Added by:  Roman Sol 
Date:  20060504 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  ZCon 2007 