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.


Added by:Roman Sol
Date:2006-05-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ZCon 2007

hide comments
2016-09-10 09:55:16
Awesome one! So, it was all about speed of 'em! :p
2015-12-14 13:38:05 Siddharth Singh
Pretty Awesome Adhoc , took me 2 days , hats off to the problem creator :)
2015-08-14 10:06:48 SangKuan
easy no need bfs.but i got 3 wa.because i treat row as column, column as row...
2014-10-24 10:28:21 Sunny
my 50th.. :) :D
2014-07-15 08:18:47 sobriquet
Amazing ADHOC.
2014-04-11 21:52:55 yousef hadder
@do_do:
think about it as if they will move in the same direction at the same time, the cat will never be able to catch the mouse, got it ?? :D
2014-04-11 21:45:47 yousef hadder
solved with Multi source BFS in 0.01S
with simple adhoc method in 0.00S
enjoyed it :D
2014-04-10 23:17:41 Petar Bosnjak
Nice one , think simple
2014-02-25 19:33:08 The Reaper
Great question. Think simple and you will get it.
2014-02-11 15:13:31 do_do
for test case 2, the first cat is at (1,3) and mouse is at (2,3)...how can mouse escape... please help me i m confused.
problem statement itself says that if one of the cat jump to field after mouse than mouse can not escape.. :(

Last edit: 2014-02-11 15:21:51
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.