COD1  Save the cows!
There is a green square grid of size nXm with k cows in it.
The objective of the cows is to escape the field.If any one of the cows escape all cows are set free.
There is a farmer who tries to restrict the field by putting up fences along the border .Initially the grid is not fenced.
Cows coordinate and think of a plan to escape.Cows get the first move.Cows and farmer move alternatively.At any move any one of the k cows can move to their neighboring cell(the cell that shares an edge with it).If the cow is already at the edge of the field and the edge is not fenced then it can escape it and hence all cows are set free.After every move of the cows the farmer can fence some edge at the border of the field of length 1 so that no cow is able to escape from that edge anymore.
The question is:"Will the innocent cows manage to escape?"
Input
First line contains Tnumber of test cases(0<T<=100)
Each test case contains 3 integers, separated by space: 1≤n,m≤100 — dimensions of the field and 0≤k≤100 — the number of cows. Each of the next k lines contains 2 integers, separated by space: 1≤x≤n, 1≤y≤m — coordinates of the corresponding cow. There could be more than one cow at a cell.
Output
Output one word: "YES" — if cows escape, "NO" — otherwise.
Example
Input:
12 2 12 2 1 1 2 Output: YES
hide comments
akshay_2000:
20210330 11:04:23
Easy one. Just think of all possibilities when the cow can't escape from the field. Last edit: 20210401 14:40:07 

dmorgans:
20190614 21:11:03
good one easy but tricky........


Liquid_Science:
20160208 15:05:04
This seems to give WA with print writer in JAVA. You have been warned . 

kancha:
20141223 19:28:21
Last edit: 20141223 20:25:21 

Jacob Plachta:
20131019 01:39:49
If there are no cows (K=0), they do not escape. 
Added by:  CSI 
Date:  20130927 
Time limit:  10s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 