Hide

Problem B
Sweet Dreams

/problems/sweetdreams/file/statement/en/img-0001.png
Red Bed, Minecraft Wiki

Unfortunately, night has fallen, and Alex has found herself alone in a field. Luckily, she has managed to make a bed, and if she can find a safe place to sleep in it, she can pass by the night without danger.

A bed is located at a single position $(x_b,y_b)$ for this problem, and can be safely slept in as long as there are no monsters within 8 blocks of you (as a straight line). In other words, a circle of radius 8 around the bed must contain no monsters (distance is measured center-to-center between blocks/objects). Can Alex get to sleep safely?

Input

The first line of input contains two integers, $x_b$ and $y_b$ $(-10^4 \le x_b,y_b \le 10^4)$, the location of your bed. For this problem you may assume that the bed and all monsters are at the same elevation. The next line contains a single integer $n$ $(0 \le n \le 10^4)$, which is the number of monsters in the area. The next $n$ lines each contain two integers $x_i$ and $y_i$ $(-10^4 \le x_i,y_i \le 10^4)$, denoting the location of the $i$th monster.

Output

Output a single string ’YES’ (without the quotes) if Alex can get to sleep safely, and ’NO’ otherwise.

Monsters exactly 8 blocks from you are considered to be within the circle.

Sample Input 1 Sample Output 1
10 5
1
2 5
NO
Sample Input 2 Sample Output 2
0 0
3
9 0
1 8
7 4
YES

Please log in to submit a solution to this problem

Log in