Vasya owns a cornfield which can be defined with two integers $n$ and $d$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $(0, d), (d, 0), (n, n - d)$ and $(n - d, n)$.

 [Image] An example of a cornfield with $n = 7$ and $d = 2$. 

Vasya also knows that there are $m$ grasshoppers near the field (maybe even inside it). The $i$-th grasshopper is at the point $(x_i, y_i)$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.

Help Vasya! For each grasshopper determine if it is inside the field (including the border).


-----Input-----

The first line contains two integers $n$ and $d$ ($1 \le d < n \le 100$).

The second line contains a single integer $m$ ($1 \le m \le 100$) — the number of grasshoppers.

The $i$-th of the next $m$ lines contains two integers $x_i$ and $y_i$ ($0 \le x_i, y_i \le n$) — position of the $i$-th grasshopper.


-----Output-----

Print $m$ lines. The $i$-th line should contain "YES" if the position of the $i$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $i$-th line should contain "NO".

You can print each letter in any case (upper or lower).


-----Examples-----
Input
7 2
4
2 4
4 1
6 3
4 5

Output
YES
NO
NO
YES

Input
8 7
4
4 4
2 8
8 1
6 1

Output
YES
NO
YES
YES



-----Note-----

The cornfield from the first example is pictured above. Grasshoppers with indices $1$ (coordinates $(2, 4)$) and $4$ (coordinates $(4, 5)$) are inside the cornfield.

The cornfield from the second example is pictured below. Grasshoppers with indices $1$ (coordinates $(4, 4)$), $3$ (coordinates $(8, 1)$) and $4$ (coordinates $(6, 1)$) are inside the cornfield.  [Image]

Difficulty: EASY
Tags: Geometry

Starter code:

Solutions:
import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def rotate(d, x, y):
	root2 = 2 ** 0.5
	x1 = x - d
	return (round(x1 / root2 + y / root2 + d, 10), round(-x1 / root2 + y / root2, 10))

def main():
	(n, d) = mi(line())
	m = iline()
	points = []
	for _ in range(m):
		points.append(tmi(line()))
	root2 = 2 ** 0.5
	inside = lambda x, y: x >= d and x <= round(root2 * (n - d) + d, 10) and (y >= 0) and (y <= round(root2 * d, 10))
	rotated_points = []
	for (x, y) in points:
		rotated_points.append(rotate(d, x, y))
	for (x, y) in rotated_points:
		if inside(x, y):
			print('YES')
		else:
			print('NO')
main()


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	x1 = x + y
	y1 = x - y
	if x1 >= d and x1 <= 2 * n - d and (abs(y1) <= d):
		print('YES')
	else:
		print('NO')


import math
a = list(map(int, input().split()))
n = a[0]
d = a[1]
o = []
g = int(input())
for i in range(g):
	k = list(map(int, input().split()))
	y1 = math.fabs(k[0]) - d
	if y1 <= k[1]:
		y2 = math.fabs(k[0] + d)
		if k[1] <= y2:
			y3 = d - k[0]
			if y3 <= k[1]:
				y4 = n - d + n - k[0]
				if y4 >= k[1]:
					k = 1
					o.append('YES')
				else:
					o.append('NO')
			else:
				o.append('NO')
		else:
			o.append('NO')
	else:
		o.append('NO')
for i in range(g):
	print(o[i])


def st(x, y, ax, ay, bx, by):
	return (bx - ax) * (y - ay) - (by - ay) * (x - ax)
(n, d) = map(int, input().split())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	p1 = st(x, y, x1, y1, x2, y2)
	p2 = st(x, y, x2, y2, x3, y3)
	p3 = st(x, y, x3, y3, x4, y4)
	p4 = st(x, y, x4, y4, x1, y1)
	if p1 <= 0 and p2 <= 0 and (p3 <= 0) and (p4 <= 0) or (p1 >= 0 and p2 >= 0 and (p3 >= 0) and (p4 >= 0)):
		print('YES')
	else:
		print('NO')


def on_field(n, d, x, y):
	return 2 * n - d >= x + y >= d and d >= x - y >= -d
(n, d) = [int(i) for i in input().split()]
print(*['YES' if on_field(n, d, *[int(i) for i in input().split()]) else 'NO' for j in range(int(input()))], sep='\n')


(n, d) = input().split()
n = int(n)
d = int(d)
m = int(input())
for i in range(0, m):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if x + y < d:
		print('NO')
	elif x > d + y:
		print('NO')
	elif x + y > 2 * n - d:
		print('NO')
	elif x < y - d:
		print('NO')
	else:
		print('YES')


spl = input().split(' ')
n = int(spl[0])
d = int(spl[1])
dots = int(input())
final = []
for dot in range(dots):
	xy = input().split(' ')
	x = int(xy[0])
	y = int(xy[1])
	br = y >= x - d
	bl = y >= -x + d
	tr = y <= -x + n + (n - d)
	tl = y <= x + d
	if br and bl and tl and tr:
		final.append('YES')
	else:
		final.append('NO')
for yn in final:
	print(yn)


from math import sqrt
initial_line = input()
initial_line_list = initial_line.split()
n = float(initial_line_list[0])
d = float(initial_line_list[1])
x_max = sqrt(2) * (n - d)
y_max = sqrt(2) * d
m = int(input())
for entry in range(m):
	current_line = input()
	current_line_list = current_line.split()
	x_initial = float(current_line_list[0])
	y_initial = float(current_line_list[1])
	x_final = (x_initial - d + y_initial) / sqrt(2)
	y_final = (-x_initial + d + y_initial) / sqrt(2)
	if x_final > x_max or y_final > y_max or x_final < 0 or (y_final < 0):
		print('NO')
	else:
		print('Yes')


nd = input().split()
n = int(nd[0])
d = int(nd[1])
m = int(input())
for i in range(m):
	cr = input().split()
	xi = int(cr[0])
	yi = int(cr[1])
	if xi + yi >= d and xi + yi <= n * 2 - d and (yi - xi <= d) and (xi - yi <= d):
		print('YES')
	else:
		print('NO')


mas = str(input()).split(' ')
n = int(mas[0])
d = int(mas[1])
kolvo = int(input())
otv = []
for i in range(kolvo):
	k = str(input()).split(' ')
	x = int(k[0])
	y = int(k[1])
	if x >= 0 and x <= n and (y >= d - x) and (y <= x + d) and (y <= 2 * n - x - d) and (y >= x - d):
		otv.append('YES')
	else:
		otv.append('NO')
for i in range(0, kolvo):
	print(otv[i])


(n, d) = map(int, input().split())
m = int(input())
a = [(0, d), (d, 0), (n, n - d), (n - d, n)]

def f(p1, p2, x, y):
	(x1, y1) = a[p1]
	(x2, y2) = a[p2]
	return (y1 - y2) * x + (x2 - x1) * y + (x1 * y2 - x2 * y1)
for i in range(m):
	(x, y) = map(int, input().split())
	print('YES' if f(0, 1, x, y) >= 0 and f(1, 2, x, y) >= 0 and (f(0, 3, x, y) <= 0) and (f(3, 2, x, y) <= 0) else 'NO')


import sys
import math
import collections
import bisect

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, d) = get_ints()
	for q in range(int(input())):
		(x, y) = get_ints()
		if d <= x + y <= 2 * n - d and -d <= y - x <= d:
			print('YES')
		else:
			print('NO')


(n, d) = [int(i) for i in input().split(' ')]
m = int(input())
a = []
for i in range(m):
	(x, y) = [int(i) for i in input().split(' ')]
	if y <= x + d and y <= -x + 2 * n - d and (y >= x - d) and (y >= d - x):
		a.append('YES')
	else:
		a.append('NO')
for i in range(len(a)):
	print(a[i])


from math import *
(n, d) = map(int, input().split())
m = int(input())

def dis(x1, y1, x2, y2, x, y):
	A = y2 - y1
	B = x1 - x2
	C = y1 * (x2 - x1) - x1 * (y2 - y1)
	return fabs(1.0 * (A * x + B * y + C) / sqrt(1.0 * (A * A + B * B)))

def check(x, y):
	global n
	global d
	if fabs(dis(d, 0, n, n - d, x, y) + dis(0, d, n - d, n, x, y) - sqrt(2.0) * d) > 1e-06:
		return False
	if fabs(dis(0, d, d, 0, x, y) + dis(n - d, n, n, n - d, x, y) - sqrt(2.0) * (n - d)) > 1e-06:
		return False
	return True
while m > 0:
	m -= 1
	(x, y) = map(int, input().split())
	if check(x, y):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
k1 = (y2 - y1) / (x2 - x1)
b1 = y1 - k1 * x1
k2 = (y3 - y2) / (x3 - x2)
b2 = y2 - k2 * x2
k3 = (y4 - y3) / (x4 - x3)
b3 = y3 - k3 * x3
k4 = (y1 - y4) / (x1 - x4)
b4 = y4 - k4 * x4
n = int(input())
answer = ''
for i in range(n):
	(x, y) = map(int, input().split())
	if y >= k1 * x + b1 and y >= k2 * x + b2 and (y <= k3 * x + b3) and (y <= k4 * x + b4):
		answer += 'YES\n'
	else:
		answer += 'NO\n'
print(answer)


(n, d) = map(int, input().split())
m = int(input())
i = int(0)
j = int(0)
c = list()
if 1 <= d <= n <= 100 and 1 <= m <= 100:
	while i < m:
		(x, y) = map(int, input().split())
		i += 1
		if not (x - y <= d and x - y >= -d):
			c.append(0)
		elif not (x + y <= n + n - d and x + y >= d):
			c.append(0)
		else:
			c.append(1)
	while j < m:
		if c[j] == 1:
			print('YES')
		else:
			print('NO')
		j += 1


(n, d) = input().split(' ')
(n, d) = (int(n), int(d))

def linedown(x):
	return x - d

def lineup(x):
	return x + d

def lineleft(x):
	return -x + d

def lineright(x):
	return -x + 2 * n - d

def infield(x, y):
	if linedown(x) <= y and lineup(x) >= y and (lineleft(x) <= y) and (lineright(x) >= y):
		return True
	else:
		return False
m = int(input())
liste = []
for i in range(m):
	(x, y) = input().split(' ')
	(x, y) = (int(x), int(y))
	if infield(x, y):
		liste.append('Yes')
	else:
		liste.append('No')
print('\n'.join(liste))


(n, d) = map(int, input().split())
k = int(input())
for i in range(k):
	(q, w) = map(int, input().split())
	if w - q <= d and q - w <= d and (q + w >= d) and (q + w <= 2 * n - d):
		print('YES')
	else:
		print('NO')


k = list(map(int, input().split()))
n = k[0]
m = k[1]
k = int(input())
for i in range(k):
	g = list(map(int, input().split()))
	x = g[0]
	y = g[1]
	if n - m > m:
		if x >= 0 and x < m and (y >= m - x) and (y <= m + x):
			print('YES')
		elif x >= m and x < n - m and (y >= x - m) and (y <= m + x):
			print('YES')
		elif x >= n - m and x <= n and (y >= x - m) and (y <= abs(n - (x - n + m))):
			print('YES')
		else:
			print('NO')
	elif x >= 0 and x < n - m and (y >= m - x) and (y <= m + x):
		print('YES')
	elif x >= n - m and x < m and (y >= m - x) and (y <= n - (x - n + m)):
		print('YES')
	elif x >= m and x <= n and (y >= x - m) and (y <= abs(n - (x - n + m))):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for x in range(m):
	(x, y) = map(int, input().split())
	if y + x - d >= 0 and y - x + d >= 0 and (y + x + d - 2 * n <= 0) and (y - x - d <= 0):
		print('YES')
	else:
		print('NO')


(n, d) = list(map(int, input().split()))
m = int(input())
a = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
	x = a[i][0]
	y = a[i][1]
	if x + y >= d and x + y <= 2 * n - d and (y >= x - d) and (y <= x + d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
lst = []
for i in range(m):
	lst.append(tuple(map(int, input().split())))
for i in range(m):
	(x, y) = (lst[i][0], lst[i][1])
	if y - x <= d and x - y <= d and (x + y >= d) and (x + y <= n * 2 - d):
		print('YES')
	else:
		print('NO')


class Point(object):

	def __init__(self, x=0, y=0, z=0):
		from numbers import Number
		assert isinstance(x, Number)
		assert isinstance(y, Number)
		assert isinstance(z, Number)
		self.abscissa = x
		self.ordinate = y
		self.applicate = z

	def distance(self, p2):
		return self.Euclidean_distance(p2)

	def Euclidean_distance(self, p2):
		x1 = self.abscissa
		x2 = p2.abscissa
		y1 = self.ordinate
		y2 = p2.ordinate
		z1 = self.applicate
		z2 = p2.applicate
		squarex = (x2 - x1) ** 2
		squarey = (y2 - y1) ** 2
		squarez = (z2 - z1) ** 2
		square_of_distance = squarex + squarey + squarez
		return square_of_distance ** 0.5

	def distance_from_origin(self):
		return self.distance(Point())

	def __str__(self):
		return (self.abscissa, self.ordinate, self.applicate)

class Rectangle(object):

	def __init__(self, p1=0, p2=0, p3=0, p4=0):
		self.p1 = p1
		self.p2 = p2
		self.p3 = p3
		self.p4 = p4

def within_rect(p, rect):
	c1 = abs(p.abscissa - rect.p2.abscissa) <= p.ordinate
	c2 = p.ordinate <= -abs(p.abscissa - rect.p4.abscissa) + rect.p4.ordinate
	spc1 = rect.p1.abscissa <= p.abscissa <= rect.p3.abscissa
	spc2 = rect.p2.ordinate <= p.ordinate <= rect.p4.ordinate
	return c1 and c2 and spc1 and spc2

def main():
	(n, d) = map(int, input().split())
	nn = max(n, d)
	dn = min(n, d)
	grasshoppersnum = int(input())
	ans = []
	r = Rectangle(Point(0, dn), Point(dn, 0), Point(nn, nn - dn), Point(nn - dn, nn))
	for i in range(grasshoppersnum):
		p = Point(*map(int, input().split()))
		ans.append(within_rect(p, r))
	for i in range(grasshoppersnum):
		if ans[i]:
			print('YES')
		else:
			print('NO')
main()


(n, d) = map(int, input().split())
m = int(input())
l = []
for i in range(m):
	l.append(input())
for ev in l:
	(x, y) = map(int, ev.split())
	if x >= 0 and x <= n and (y >= 0) and (y <= n):
		if x <= d and y <= d and (x + y < d):
			print('NO')
		elif x <= n - d and y >= d and (x - y < 0 - d):
			print('NO')
		elif x >= n - d and y <= n and (x + y > 2 * n - d):
			print('NO')
		elif x >= d and y <= n - d and (x - y > d):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
ot = []
while m > 0:
	(x, y) = map(int, input().split())
	if y >= d - x and y <= n + d - n + x and (y <= n + n - d - x) and (y >= -d + x):
		ot.append(1)
		m -= 1
	else:
		ot.append(0)
		m -= 1
for i in range(0, len(ot)):
	if int(ot[i]) == 1:
		print('YES')
	else:
		print('NO')


def check(x, y, n, d):
	if (d <= x + y and x + y <= 2 * n - d) and -d <= x - y and (x - y <= d):
		return 'YES'
	else:
		return 'NO'
field_coords = list(map(int, input().split(' ')))
n = field_coords[0]
d = field_coords[1]
arr = []
cnt = int(input())
for i in range(0, cnt):
	kuz_coords = list(map(int, input().split(' ')))
	arr.append(kuz_coords)
for i in range(0, len(arr)):
	print(check(arr[i][0], arr[i][1], n, d))


(n, d) = input().split()
n = int(n)
d = int(d)
ans = []
t = int(input())
for i in range(t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if (y >= d - x and y <= x + d) and (y <= 2 * n - d - x and y >= x - d):
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


(n, d) = map(int, input().split())
k1 = 1
k2 = -1
b11 = d
b12 = -d
b21 = n - (n - d) * k2
b22 = d
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if y <= k1 * x + b11 and y >= k1 * x + b12 and (y <= k2 * x + b21) and (y >= k2 * x + b22):
		print('YES')
	else:
		print('NO')


import sys
import math
(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	ok = True
	if not (x - y <= d and x - y >= -1 * d):
		ok = False
	if not (x + y <= n + n - d and x + y >= d):
		ok = False
	print('YES' if ok else 'NO')


nStr = input().split(' ')
n = int(nStr[0])
d = int(nStr[1])
m = int(input())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
for i in range(m):
	stroka = input().split(' ')
	Px = int(stroka[0])
	Py = int(stroka[1])
	Dx = x2 - x1
	Dy = y2 - y1
	d1 = ((y1 - Py) * Dx + (Px - x1) * Dy) / (Dy * Dy + Dx * Dx)
	Dx = x3 - x2
	Dy = y3 - y2
	d2 = ((y2 - Py) * Dx + (Px - x2) * Dy) / (Dy * Dy + Dx * Dx)
	Dx = x4 - x3
	Dy = y4 - y3
	d3 = ((y3 - Py) * Dx + (Px - x3) * Dy) / (Dy * Dy + Dx * Dx)
	Dx = x1 - x4
	Dy = y1 - y4
	d4 = ((y4 - Py) * Dx + (Px - x4) * Dy) / (Dy * Dy + Dx * Dx)
	if d1 <= 0 and d2 <= 0 and (d3 <= 0) and (d4 <= 0):
		print('YES')
	else:
		print('NO')


A = input().split()
B = input()
Answ = []
for i in range(int(B)):
	Koor = input().split()
	if int(Koor[1]) <= int(Koor[0]) + int(A[1]) and int(Koor[1]) >= int(Koor[0]) - int(A[1]) and (int(Koor[1]) >= -1 * int(Koor[0]) + int(A[1])) and (int(Koor[1]) <= -1 * int(Koor[0]) + 2 * int(A[0]) - int(A[1])):
		Answ.append('YES')
	else:
		Answ.append('NO')
for i in range(int(B)):
	print(Answ[i])


(n, m) = [int(i) for i in input().split(' ')]
q = int(input())
for i in range(0, q):
	(x, y) = [int(i) for i in input().split(' ')]
	if -m <= y - x <= m and m <= y + x <= 2 * n - m:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
ans = 0
for i in range(m):
	(x, y) = map(int, input().split())
	if y > x + d or y < x - d or y < -x + d or (y > -x + 2 * n - d):
		print('NO')
	else:
		print('YES')


d = input('').split(' ')
n = int(input(''))
b1 = int(d[1])
b2 = int(d[1])
b3 = 2 * int(d[0]) - int(d[1])
b4 = int(d[1]) * -1
ot = []
for i in range(0, n):
	t = input('').split(' ')
	x = int(t[0])
	y = int(t[1])
	if (y >= b1 - x) & (y <= x + b2) & (y <= b3 - x) & (y >= x + b4):
		ot.append('YES')
	else:
		ot.append('NO')
for i in range(len(ot)):
	print(ot[i])


def F(px, py, ax, ay, bx, by):
	return (bx - ax) * (py - ay) - (by - ay) * (px - ax)
(n, d) = list(map(int, input().split()))
m = int(input())
for i in range(m):
	(x, y) = list(map(int, input().split()))
	if F(x, y, d, 0, n, n - d) >= 0 and F(x, y, n, n - d, n - d, n) >= 0 and (F(x, y, n - d, n, 0, d) >= 0) and (F(x, y, 0, d, d, 0) >= 0):
		print('YES')
	else:
		print('NO')


def make_line(x1, y1, x2, y2):
	b = (x1 * y2 - x2 * y1) / (x1 - x2)
	k = (y1 - y2) / (x1 - x2)
	return (k, b)
(n, d) = map(int, input().split())
(k1, b1) = make_line(0, d, d, 0)
(k2, b2) = make_line(0, d, n - d, n)
(k3, b3) = make_line(n - d, n, n, n - d)
(k4, b4) = make_line(n, n - d, d, 0)
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if y >= k1 * x + b1 and y <= k2 * x + b2 and (y <= k3 * x + b3) and (y >= k4 * x + b4):
		print('YES')
	else:
		print('NO')


(n, d) = [int(z) for z in input().split(' ')]
m = int(input())
for i in range(m):
	(x, y) = [int(z) for z in input().split(' ')]
	print('YES' if (y <= x + d and y >= x - d) and (x >= d - y and x <= 2 * n - d - y) else 'NO')


(n, d) = [int(i) for i in input().split()]
m = int(input())
kuzn = []
res = []
for i in range(m):
	kuzn.append([int(i) for i in input().split()])
for k in kuzn:
	xK = k[0]
	yK = k[1]
	yMax = xK + d
	yMin = xK - d
	xMax = 2 * n - d - yK
	xMin = d - yK
	if (yMin <= yK and yK <= yMax) and (xMin <= xK and xK <= xMax):
		res.append('YES')
	else:
		res.append('NO')
for i in res:
	print(i)


import math

class Vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __neg__(self):
		return Vector(-self.x, -self.y)

	def __sub__(self, other):
		return self + -other

	def __len__(self):
		return math.sqrt(self.x ** 2 + self.y ** 2)

def dot(a, b):
	return a.x * b.x + a.y * b.y

def cross(a, b):
	return a.x * b.y - a.y * b.x
(n, d) = map(int, input().split())
p1 = (0, d)
p2 = (d, 0)
p3 = (n, n - d)
p4 = (n - d, n)
vec1 = Vector(d, -d)
vec2 = Vector(n - d, n - d)
vec3 = Vector(-d, d)
vec4 = Vector(d - n, d - n)
m = int(input())
for i in range(m):
	base = tuple(map(int, input().split()))
	vec5 = Vector(base[0] - p1[0], base[1] - p1[1])
	if cross(vec1, vec5) < 0:
		print('NO')
		continue
	vec5 = Vector(base[0] - p2[0], base[1] - p2[1])
	if cross(vec2, vec5) < 0:
		print('NO')
		continue
	vec5 = Vector(base[0] - p3[0], base[1] - p3[1])
	if cross(vec3, vec5) < 0:
		print('NO')
		continue
	vec5 = Vector(base[0] - p4[0], base[1] - p4[1])
	if cross(vec4, vec5) < 0:
		print('NO')
		continue
	print('YES')


(n, d) = input('').split()
n = int(n)
d = int(d)
m = int(input(''))
t = []
r = []
i = 0
for i in range(m):
	(a, b) = input('').split()
	r.append(int(b))
	t.append(int(a))
for i in range(m):
	if r[i] >= d - t[i] and r[i] >= t[i] - d and (r[i] <= t[i] + d) and (r[i] <= 2 * n - d - t[i]):
		print('YES')
	else:
		print('NO')


def grasshoperInTheField(n, d, x, y):
	summ = x + y
	subb = x - y
	if d <= summ:
		if 2 * n - d >= summ:
			if -d <= subb:
				if d >= subb:
					return 'YES'
	return 'NO'
(n, d) = [int(i) for i in input().split()]
m = int(input())
for k in range(m):
	(x, y) = [int(i) for i in input().split()]
	print(grasshoperInTheField(n, d, x, y))


arr = list(map(int, input().split()))
v4 = [0, arr[1]]
v1 = [arr[1], 0]
v2 = [arr[0], arr[0] - arr[1]]
v3 = [arr[0] - arr[1], arr[0]]

def slope(x1, y1, x2, y2):
	return (y2 - y1) / (x2 - x1)

def l1(v1, v2, x, y):
	m = slope(v1[0], v1[1], v2[0], v2[1])
	c = v2[1] - m * v2[0]
	res = y - m * x - c
	if res >= 0:
		return 1
	else:
		return 0

def l2(v2, v3, x, y):
	m = slope(v2[0], v2[1], v3[0], v3[1])
	c = v2[1] - m * v2[0]
	res = y - m * x - c
	if res <= 0:
		return 1
	else:
		return 0

def l3(v3, v4, x, y):
	m = slope(v3[0], v3[1], v4[0], v4[1])
	c = v3[1] - m * v3[0]
	res = y - m * x - c
	if res <= 0:
		return 1
	else:
		return 0

def l4(v4, v1, x, y):
	m = slope(v4[0], v4[1], v1[0], v1[1])
	c = v1[1] - m * v1[0]
	res = y - m * x - c
	if res >= 0:
		return 1
	else:
		return 0
n = int(input())
for i in range(n):
	query = list(map(int, input().split()))
	x = query[0]
	y = query[1]
	if l1(v1, v2, x, y) and l2(v2, v3, x, y) and l3(v3, v4, x, y) and l4(v4, v1, x, y):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
m = int(input())
s1 = 0.5 * abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1))
s2 = 0.5 * abs((x4 - x1) * (y3 - y1) - (y4 - y1) * (x3 - x1))
S = s1 + s2
for i in range(m):
	(x0, y0) = map(int, input().split())
	s1 = 0.5 * abs((x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0))
	s2 = 0.5 * abs((x2 - x0) * (y3 - y0) - (y2 - y0) * (x3 - x0))
	s3 = 0.5 * abs((x3 - x0) * (y4 - y0) - (y3 - y0) * (x4 - x0))
	s4 = 0.5 * abs((x0 - x4) * (y1 - y4) - (y0 - y4) * (x1 - x4))
	if s1 + s2 + s3 + s4 == S:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
down = d
left = -d
right = d
up = 2 * n - d
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(x, y) = (x - y, x + y)
	if left <= x <= right and down <= y <= up:
		print('YES')
	else:
		print('NO')


inhalf = lambda A, B, C, p: A * p[0] + B * p[1] + C >= 0
inR = lambda n, d, p: inhalf(1, 1, -d, p) and inhalf(-1, -1, (n << 1) - d, p) and inhalf(1, -1, d, p) and inhalf(-1, 1, d, p)
(n, d) = list(map(int, input().split()))
ps = [list(map(int, input().split())) for i in range(int(input()))]
[print('YES' if inR(n, d, p) else 'NO') for p in ps]


class CartesianSquare:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

	def is_point_inside(self, x, y):
		return x + y - self.p2 >= 0 and x - y - self.p2 <= 0 and (x + y - 2 * self.p1 + self.p2 <= 0) and (x - y + self.p2 >= 0)
(n, d) = [int(x) for x in input().split()]
grasshoppers = int(input())
cs = CartesianSquare(n, d)
for _ in range(grasshoppers):
	(xi, yi) = [int(x) for x in input().split()]
	if cs.is_point_inside(xi, yi):
		print('YES')
	else:
		print('NO')


def f(t1, t2, x):
	k = (t1[1] - t2[1]) / (t1[0] - t2[0])
	b = t2[1] - k * t2[0]
	return k * x + b
(n, d) = map(int, input().split())
k = int(input())
t1 = (0, d)
t2 = (d, 0)
t3 = (n - d, n)
t4 = (n, n - d)
a = []
for i in range(k):
	(x, y) = map(int, input().split())
	a.append((x, y))
for kuz in a:
	print('YES' if kuz[1] >= f(t1, t2, kuz[0]) and kuz[1] >= f(t2, t4, kuz[0]) and (kuz[1] <= f(t1, t3, kuz[0])) and (kuz[1] <= f(t3, t4, kuz[0])) else 'NO')


(n, d) = [int(i) for i in input().split()]
m = int(input())
k1 = (0 - d) / (d - 0)
k2 = (d - n) / (d - n)
k3 = d / (-1 * d)
k4 = (n - d) / (n - d)
m1 = 0 - k1 * d
m2 = d
m3 = n - k3 * (n - d)
m4 = n - d - k4 * n
ans = []
for i in range(m):
	(x, y) = [int(i) for i in input().split()]
	if (y - m1) / k1 <= x and (y - m2) / k2 <= x and ((y - m3) / k3 >= x) and ((y - m4) / k4 >= x):
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
	(n, d) = read_tuple(int)
	m = int(input())
	for _ in range(m):
		(x, y) = read_tuple(int)
		if d <= x + y <= 2 * n - d and -d <= x - y <= d:
			print('YES')
		else:
			print('NO')
solve()


(n, d) = [int(a) for a in input().split()]
output = []
for i in range(int(input())):
	(x, y) = [int(a) for a in input().split()]
	if -x + d <= y and x + d >= y and (-x + 2 * n - d >= y) and (x - d <= y):
		output.append('YES')
	else:
		output.append('NO')
print('\n'.join(output))


(n, d) = map(int, input().split())
i = int(input())
while i:
	i -= 1
	(x, y) = map(int, input().split())
	if (x + y - d) * (x + y - 2 * n + d) > 0 or (x - y - d) * (x - y + d) > 0:
		print('NO')
	else:
		print('YES')


def D(p1, p2, pc):
	(x1, y1) = p1
	(x2, y2) = p2
	(xp, yp) = pc
	return (x2 - x1) * (yp - y1) - (xp - x1) * (y2 - y1)
(n, d) = [int(i) for i in input().split()]
one = (0, d)
two = (n - d, n)
three = (n, n - d)
four = (d, 0)
cnt = int(input())
ans = []
for _ in range(cnt):
	(x, y) = [int(i) for i in input().split()]
	p1 = D(one, two, (x, y))
	p2 = D(two, three, (x, y))
	p3 = D(three, four, (x, y))
	p4 = D(four, one, (x, y))
	if p1 <= 0 and p2 <= 0 and (p3 <= 0) and (p4 <= 0):
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


(n, d) = map(int, input().split())
m = int(input())
ans = []
for i in range(m):
	(x, y) = map(int, input().split())
	if abs(x - y) <= d and x + y >= d and (x + y <= n + n - d):
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


def sign(x):
	if x > 0:
		return 1
	if x < 0:
		return -1
	return 0

class vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

class line:

	def __init__(self, x1, y1, x2, y2):
		self.x1 = x1
		self.y1 = y1
		self.x2 = x2
		self.y2 = y2

	def above(self, x, y):
		v1 = vector(self.x2 - self.x1, self.y2 - self.y1)
		v2 = vector(x - self.x1, y - self.y1)
		xp = v1.x * v2.y - v1.y * v2.x
		return sign(xp)
(n, d) = map(int, input().split())
m = int(input())
x = [0] * m
y = [0] * m
for i in range(m):
	(x[i], y[i]) = map(int, input().split())
lines = [line(0, d, n - d, n), line(n - d, n, n, n - d), line(n, n - d, d, 0), line(d, 0, 0, d)]
res = 0
p = [0] * 4
for i in range(m):
	for j in range(4):
		p[j] = lines[j].above(x[i], y[i])
	if p[0] <= 0 and p[1] <= 0 and (p[2] <= 0) and (p[3] <= 0):
		print('YES')
	else:
		print('NO')


def main():
	(n, d) = map(int, input().split())
	m = int(input())
	for _ in range(m):
		(x, y) = map(int, input().split())
		if y < x - d or y > x + d:
			print('NO')
			continue
		print('YES' if -x + d <= y <= -x + 2 * n - d else 'NO')
main()


import sys
args = sys.stdin.read().splitlines()
(n, d) = [int(x) for x in args[0].split(' ')]
m = int(args[1])
points = args[2:]

def in_rectangle(x, y):
	return y >= x - d and y <= x + d and (y >= -x + d) and (y <= -x + 2 * n - d)
for point in points:
	(x, y) = [int(x) for x in point.split(' ')]
	if in_rectangle(x, y):
		print('YES')
	else:
		print('NO')


(n, d) = input().split()
n = int(n)
d = int(d)
ed = {}
for i in range(d + 1):
	ed[d - i, i] = 1
	ed[n - i, n - d + i] = 2
for i in range(abs(n - d)):
	ed[d + i, i] = 1
	ed[i, i + d] = 2
ed[0, d] = 3
ed[n, n - d] = 3
m = int(input())
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	flag = 1
	if (x, y) in ed:
		print('YES')
		continue
	else:
		for co in ed.keys():
			if co[0] == x:
				if ed[co] == 1:
					if co[1] > y:
						print('NO')
						flag = 0
						break
				elif ed[co] == 2:
					if co[1] < y:
						print('NO')
						flag = 0
						break
				elif y != co[1]:
					print('NO')
					flag = 0
					break
	if flag:
		print('YES')


(n, d) = map(int, input().split())

def k(x, y):
	if y >= x - d and y <= x + d and (y >= -x + d) and (y <= -x + 2 * n - d):
		return 1
	else:
		return 0
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if k(x, y):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
a = []
for i in range(m):
	(x1, y1) = map(int, input().split())
	t1 = x1 + y1
	t2 = x1 - y1
	if t1 >= d and t1 <= 2 * n - d and (t2 >= -d) and (t2 <= d):
		a.append('YES')
	else:
		a.append('NO')
for j in a:
	print(j)


p = input().split()
n = int(p[0])
d = int(p[1])
x = []
y = []
m = int(input())
for i in range(m):
	p = input().split()
	x.append(int(p[0]))
	y.append(int(p[1]))
	if x[i] + y[i] >= d and x[i] + y[i] <= 2 * n - d and (x[i] - y[i] >= -d) and (x[i] - y[i] <= d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
k = int(input())
ans = []
for i in range(k):
	(x, y) = map(int, input().split())
	ox = x <= y + d and x >= y - d and (x >= d - y) and (x <= -1 * y + 2 * n - d)
	oy = y <= x + d and y >= x - d and (y >= d - x) and (y <= -1 * x + 2 * n - d)
	if ox and oy:
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


def area(x1, y1, x2, y2, x3, y3):
	return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0)

def check(x1, y1, x2, y2, x3, y3, x4, y4, x, y):
	A = area(x1, y1, x2, y2, x3, y3) + area(x1, y1, x4, y4, x3, y3)
	A1 = area(x, y, x1, y1, x2, y2)
	A2 = area(x, y, x2, y2, x3, y3)
	A3 = area(x, y, x3, y3, x4, y4)
	A4 = area(x, y, x1, y1, x4, y4)
	return A == A1 + A2 + A3 + A4
(n, d) = map(int, input().split())
m = int(input())
(x1, y1, x2, y2, x3, y3, x4, y4) = (0, d, d, 0, n, n - d, n - d, n)
for i in range(m):
	(x, y) = map(int, input().split())
	if check(x1, y1, x2, y2, x3, y3, x4, y4, x, y):
		print('YES')
	else:
		print('NO')


def isin(x, y, n, d):
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + 2 * n - d):
		return 'YES'
	return 'NO'
a = input().split()
n = int(a[0])
d = int(a[1])
a = int(input())
tmp = []
for i in range(a):
	b = input().split()
	tmp.append(isin(int(b[0]), int(b[1]), n, d))
for i in tmp:
	print(i)


class Point:

	def __init__(self, x_, y_):
		self.x = x_
		self.y = y_

class Vec:

	def __init__(self, p1, p2):
		self.x = p2.x - p1.x
		self.y = p2.y - p1.y

def mul(v1, v2):
	return v1.x * v2.y - v1.y * v2.x
(n, d) = map(int, input().split())
points = [Point(0, d), Point(d, 0), Point(n, n - d), Point(n - d, n)]
vecs = [Vec(points[0], points[1]), Vec(points[1], points[2]), Vec(points[2], points[3]), Vec(points[3], points[0])]
m = int(input())
for i in range(m):
	inp = True
	(x, y) = map(int, input().split())
	for i in range(4):
		p = points[i]
		v = vecs[i]
		v2 = Vec(p, Point(x, y))
		if mul(v, v2) < 0:
			inp = False
			break
	print('YES' if inp else 'NO')


(n, d) = map(int, input().split())
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	if d <= x + y <= 2 * n - d and -d <= x - y <= d:
		print('YES')
	else:
		print('NO')


read = lambda : [int(c) for c in input().split()]

def main():
	(n, d) = read()
	m = read()[0]
	for _ in range(m):
		(x, y) = read()
		cond = x - d <= y <= x + d and -x + d <= y <= -x + 2 * n - d
		print('YES' if cond else 'NO')
main()


(n, d) = map(int, input().split())
f = lambda x, y: (x + y - d) * (y - x - d) * (y - x + d) * (y + x + d - 2 * n)
tc = int(input())
while tc != 0:
	tc -= 1
	(x, y) = map(int, input().split())
	flag = False
	if f(n / 2, n / 2) >= 0:
		Flag = True
	if flag:
		if f(x, y) <= 0:
			print('YES')
		else:
			print('NO')
	elif f(x, y) >= 0:
		print('YES')
	else:
		print('NO')


def cross(p1, p2, p):
	return (p2[0] - p1[0]) * (p[1] - p1[1]) - (p[0] - p1[0]) * (p2[1] - p1[1])
(n, d) = map(int, input().split())
m = eval(input())
p1 = [0, d]
p2 = [d, 0]
p3 = [n, n - d]
p4 = [n - d, n]
for i in range(m):
	px = [int(x) for x in input().split()]
	if cross(p1, p2, px) * cross(p3, p4, px) >= 0 and cross(p2, p3, px) * cross(p4, p1, px) >= 0:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if x + y < d:
		print('NO')
	elif x > n or y > n:
		print('NO')
	elif x + y > 2 * n - d:
		print('NO')
	elif abs(x - y) > d:
		print('NO')
	else:
		print('YES')


def kuzn(n1, d1, x1, y1):
	if x1 > n1 or y1 > n1:
		return 0
	elif x1 == n1:
		if y1 == n1 - d1:
			return 1
		else:
			return 0
	elif y1 == n1:
		if x1 == n1 - d1:
			return 1
		else:
			return 0
	if y1 + x1 < d1:
		return 0
	if y1 + x1 == d1:
		return 1
	if y1 - x1 > d1:
		return 0
	if y1 - x1 == d1:
		return 1
	if x1 - y1 > d1:
		return 0
	if x1 - y1 == d1:
		return 1
	if y1 + x1 > 2 * n1 - d1:
		return 0
	return 1
(n, d) = [int(i) for i in input().split()]
for j in range(int(input())):
	(x, y) = map(int, input().split())
	print('YES' if kuzn(n, d, x, y) else 'NO')


(n, d) = map(int, input().split())
m = int(input())
ar = [[0 for i in range(n + 1)] for i in range(n + 1)]
for i in range(n + 1):
	for j in range(n + 1):
		if i + j < d or i - j > d or i + j > n * 2 - d or (j - i > d):
			pass
		else:
			ar[i][j] = 1
for i in range(m):
	(x, y) = map(int, input().split())
	if ar[x][y] == 0:
		print('NO')
	else:
		print('YES')


(n, d) = map(int, input().split())
m = int(input())
updiag = n - d + n
lowdiag = d + 0
rdiag = 0 - d
ldiag = d - 0
l = [0] * m
for i in range(m):
	(x, y) = map(int, input().split())
	if lowdiag <= x + y <= updiag:
		if rdiag <= y - x <= ldiag:
			l[i] = 1
for j in l:
	if j == 1:
		print('YES')
	else:
		print('NO')


def test(x, y):
	if d <= x + y <= 2 * n - d and abs(x - y) <= d:
		print('yes')
	else:
		print('no')
(n, d) = map(int, input().split())
for i in range(int(input())):
	test(*[int(j) for j in input().split()])


(n, d) = map(int, input().split())
m = int(input())
lst = []
x1 = 0
y1 = d
x2 = n - d
y2 = n
x3 = n
y3 = n - d
x4 = d
y4 = 0
for i in range(m):
	(x, y) = map(int, input().split())
	d1 = (x - x1) * (y2 - y1) - (y - y1) * (x2 - x1)
	d2 = (x - x2) * (y3 - y2) - (y - y2) * (x3 - x2)
	d3 = (x - x3) * (y4 - y3) - (y - y3) * (x4 - x3)
	d4 = (x - x4) * (y1 - y4) - (y - y4) * (x1 - x4)
	if d1 >= 0 and d2 >= 0 and (d3 >= 0) and (d4 >= 0):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
output = list()
for i in range(0, m):
	(x, y) = map(int, input().split())
	if x + d >= y and y + d >= x and (x + y >= d) and (x + y <= n + (n - d)):
		output += ['YES']
	else:
		output += ['NO']
for i in output:
	print(i)


(n, d) = map(int, input().split())
hoppers = int(input())
res = []
for i in range(hoppers):
	(x, y) = map(int, input().split())
	if abs(x - y) <= d and x + y >= d and (x + y <= 2 * n - d):
		res.append('YES')
	else:
		res.append('NO')
print(*res, sep='\n')


class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

class Vector:

	def __init__(self, begin, end):
		self.x = end.x - begin.x
		self.y = end.y - begin.y

	def mult(self, other):
		return self.x * other.y - self.y * other.x
(n, d) = list(map(int, input().split()))
m = int(input())
ans = []
vector1 = Vector(Point(d, 0), Point(0, d))
vector2 = Vector(Point(d, 0), Point(n, n - d))
vector3 = Vector(Point(n - d, n), Point(0, d))
vector4 = Vector(Point(n - d, n), Point(n, n - d))
for i in range(m):
	(x, y) = list(map(int, input().split()))
	vector15 = Vector(Point(d, 0), Point(x, y))
	vector35 = Vector(Point(n - d, n), Point(x, y))
	if vector15.mult(vector1) * vector15.mult(vector2) <= 0 and vector35.mult(vector3) * vector35.mult(vector4) <= 0:
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


(n, d) = input().split()
d = int(d)
n = int(n)
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
m = int(input())
for i in range(0, m):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	s = abs((x1 - x2) * (y3 - y2) - (y1 - y2) * (x3 - x2)) + abs((x4 - x2) * (y3 - y2) - (y4 - y2) * (x3 - x2))
	s1 = abs((x1 - x2) * (y - y2) - (y1 - y2) * (x - x2))
	s2 = abs((x - x2) * (y3 - y2) - (y - y2) * (x3 - x2))
	s3 = abs((x - x4) * (y3 - y4) - (y - y4) * (x3 - x4))
	s4 = abs((x - x4) * (y1 - y4) - (y - y4) * (x1 - x4))
	if s == s1 + s2 + s3 + s4:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print('YES' if abs(a - b) <= d and d <= a + b <= 2 * n - d else 'NO')


(n, d) = [int(cord) for cord in input().split(' ')]
motherfuckers = int(input())
for i in range(motherfuckers):
	(x, y) = [int(cord) for cord in input().split(' ')]
	if y <= x + d and y >= x * -1 + d and (y >= x - d) and (y <= x * -1 + d + (n - d) * 2):
		print('YES')
	else:
		print('NO')


(n, d) = [int(s) for s in input().split(' ')]
m = int(input())
for g in range(m):
	(x, y) = [int(s) for s in input().split(' ')]
	if d <= x + y <= 2 * n - d and -d <= y - x <= d:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
for i in range(int(input())):
	res = 'no'
	(x, y) = map(int, input().split())
	yab = -x + d
	ycd = -x + 2 * n - d
	ybd = x - d
	yac = x + d
	if y >= yab and y <= ycd and (y >= ybd) and (y <= yac):
		res = 'yes'
	print(res)


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x5, y5) = map(int, input().split())
	if x5 + y5 < d or x5 + y5 > 2 * n - d or x5 + (n - y5) < n - d or (n - x5 + y5 < n - d):
		print('NO')
	else:
		print('YES')


(n, d) = [int(x) for x in input().split()]
for i in range(int(input())):
	(x, y) = [int(j) for j in input().split()]
	if (d <= x + y and x + y <= n + n - d) and (y <= x + d and y >= x - d):
		print('YES')
	else:
		print('NO')


def f(p1, p2, p):
	a = p[1] - (p[0] - p1[0]) * (p2[1] - p1[1]) / (p2[0] - p1[0]) - p1[1]
	return a
(n, d) = map(int, input().split())
p1 = (0, d)
p2 = (d, 0)
p3 = (n, n - d)
p4 = (n - d, n)
m = int(input())
for i in range(m):
	p = tuple(map(int, input().split()))
	if f(p1, p2, p) >= 0 and f(p2, p3, p) >= 0 and (f(p3, p4, p) <= 0) and (f(p1, p4, p) <= 0):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
p1 = (d, 0)
p2 = (0, d)
p3 = (n - d, n)
p4 = (n, n - d)
for i in range(m):
	(x, y) = map(int, input().split())
	if (p1[1] - p2[1]) * x + (p2[0] - p1[0]) * y + (p1[0] * p2[1] - p2[0] * p1[1]) <= 0:
		if (p2[1] - p3[1]) * x + (p3[0] - p2[0]) * y + (p2[0] * p3[1] - p3[0] * p2[1]) <= 0:
			if (p3[1] - p4[1]) * x + (p4[0] - p3[0]) * y + (p3[0] * p4[1] - p4[0] * p3[1]) <= 0:
				if (p4[1] - p1[1]) * x + (p1[0] - p4[0]) * y + (p4[0] * p1[1] - p1[0] * p4[1]) <= 0:
					print('YES')
					continue
	print('NO')


(n, d) = [int(x) for x in input().split()]
m = int(input())
for i in range(m):
	(a, b) = [int(x) for x in input().split()]
	if abs(a - b) <= d and d <= a + b <= 2 * n - d:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
k = 0
m = int(input())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
for i in range(1, m + 1):
	(x, y) = map(int, input().split())
	if y <= (y4 - y1) / (x4 - x1) * x + (y1 - (y4 - y1) / (x4 - x1) * x1) and y <= (y3 - y4) / (x3 - x4) * x + (y4 - (y3 - y4) / (x3 - x4) * x4) and (y >= (y2 - y3) / (x2 - x3) * x + (y3 - (y2 - y3) / (x2 - x3) * x3)) and (y >= (y1 - y2) / (x1 - x2) * x + (y2 - (y1 - y2) / (x1 - x2) * x2)):
		print('YES')
	else:
		print('NO')


def rek(tp, ta, tb):
	return (tb[0] - ta[0]) * (tp[1] - ta[1]) - (tb[1] - ta[1]) * (tp[0] - ta[0])
(n, d) = map(int, input().split())
t1 = [0, d]
t2 = [d, 0]
t3 = [n, n - d]
t4 = [n - d, n]
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	p = [x, y]
	r1 = rek(p, t1, t2)
	r2 = rek(p, t2, t3)
	r3 = rek(p, t3, t4)
	r4 = rek(p, t4, t1)
	if r1 <= 0 and r2 <= 0 and (r3 <= 0) and (r4 <= 0) or (r1 >= 0 and r2 >= 0 and (r3 >= 0) and (r4 >= 0)):
		print('YES')
	else:
		print('NO')


def yes(x, y):
	global n, d
	return 'YES' if y >= -x + n and y >= x - n and (y <= -x + d + d - n) and (y <= x + n) else 'NO'
(d, n) = map(int, input().split())
k = int(input())
for i in range(k):
	(x1, y1) = map(int, input().split())
	print(yes(x1, y1))


def area(coords):
	len_coords = len(coords)
	res = 0
	for i in range(0, len_coords - 1):
		res += coords[i][0] * coords[i + 1][1] - coords[i + 1][0] * coords[i][1]
	res += coords[len_coords - 1][0] * coords[0][1] - coords[0][0] * coords[len_coords - 1][1]
	res /= 2
	return res if res > 0 else -res
(n, d) = (int(i) for i in input().split())
coords = [(0, d), (d, 0), (n, n - d), (n - d, n)]
retArea = area(coords)
n = int(input())
for _ in range(n):
	(p1, p2) = (int(i) for i in input().split())
	a1 = area([coords[0], (p1, p2), coords[3]])
	a2 = area([coords[3], (p1, p2), coords[2]])
	a3 = area([coords[2], (p1, p2), coords[1]])
	a4 = area([(p1, p2), coords[1], coords[0]])
	if a1 + a2 + a3 + a4 > retArea:
		print('NO')
	else:
		print('YES')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	test = 'YES'
	if (x > n or y > n) or x + y < d or 2 * n - x - y < d or (n - max(x, y) + min(x, y) < n - d):
		test = 'NO'
	print(test)


n = input().split()
(n, d) = (int(n[0]), int(n[1]))
liste = []
for i in range(int(input())):
	s = input().split()
	liste.append((int(s[0]), int(s[1])))
for j in liste:
	(x, y) = (j[0], j[1])
	if (y >= -x + d and y <= x + d) and (y <= -x + 2 * n - d and y >= x - d):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout, setrecursionlimit
from gc import disable
disable()
gets = input
puts = print
input = stdin.readline
print = stdout.write
from math import fabs

def s(fig: list) -> float:
	res = 0
	for i in range(len(fig)):
		p1 = fig[i - 1] if i else fig[-1]
		p2 = fig[i]
		res += (p1[0] - p2[0]) * (p1[1] + p2[1])
	return fabs(res) / 2

def check(fig: list, point: int) -> bool:
	ss = s((fig[0], fig[1], point)) + s((fig[1], fig[2], point)) + s((fig[2], fig[3], point)) + s((fig[3], fig[0], point))
	return ss == s(fig)

def main() -> int:
	(n, d) = map(int, input().split())
	p1 = (0, d)
	p2 = (d, 0)
	p3 = (n, n - d)
	p4 = (n - d, n)
	fig = [p1, p2, p3, p4]
	m = int(input())
	points = [tuple(map(int, input().split())) for i in range(m)]
	for i in range(m):
		if check(fig, points[i]):
			print('YES\n')
		else:
			print('NO\n')
	return 0
main()


(n, d) = tuple(map(int, input().split()))
m = int(input())
p = []
for i in range(m):
	(x, y) = tuple(map(int, input().split()))
	if y >= -x + d and y <= -x + 2 * n - d and (y <= x + d) and (y >= x - d):
		p.append('YES')
	else:
		p.append('NO')
for i in p:
	print(i)


(n, d) = map(int, input().split())
q = int(input())
s1 = [0, d]
s2 = [d, 0]
s3 = [n, n - d]
s4 = [n - d, n]
for i in range(q):
	(x, y) = map(int, input().split())
	if x - y + d > 0 and x - y - d > 0:
		print('NO')
	elif x - y + d < 0 and x - y - d < 0:
		print('NO')
	elif x + y - d > 0 and x + y - 2 * n + d > 0:
		print('NO')
	elif x + y - d < 0 and x + y - 2 * n + d < 0:
		print('NO')
	else:
		print('YES')


(n, d) = map(int, input().split())
A = (0, d)
B = (d, 0)
C = (n - d, n)
D = (n, n - d)

def cross2(A, B):
	return A[0] * B[1] - A[1] * B[0]

def cross(p, A, B):
	return cross2(A, B) - cross2(A, p) - cross2(p, B)

def inTri(p, A, B, C):
	s1 = cross(p, A, B)
	s2 = cross(p, B, C)
	s3 = cross(p, C, A)
	if s1 == 0 or s2 == 0 or s3 == 0:
		return True
	if s1 > 0 and s2 > 0 and (s3 > 0):
		return True
	return s1 < 0 and s2 < 0 and (s3 < 0)
m = int(input())
ans = ['' for i in range(m)]
for i in range(m):
	p = tuple(map(int, input().split()))
	ans[i] = 'YES' if inTri(p, A, B, C) or inTri(p, D, B, C) else 'NO'
print('\n'.join(ans))


def left_down(x, y, b):
	if y >= -x + b:
		return True
	return False

def right_down(x, y, b):
	if y >= x - b:
		return True
	return False

def left_up(x, y, b):
	if y <= -x + b:
		return True
	return False

def right_up(x, y, b):
	if y <= x + b:
		return True
	return False

def f(n, d, x, y):
	a = []
	a.append(left_down(x, y, d))
	a.append(right_down(x, y, d))
	a.append(left_up(x, y, 2 * n - d))
	a.append(right_up(x, y, d))
	if False in a:
		return 'NO'
	return 'YES'
(n, d) = map(int, input().split())
m = int(input())
xy = []
for i in range(m):
	(x, y) = map(int, input().split())
	xy.append([x, y])
for i in xy:
	print(f(n, d, i[0], i[1]))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, d) = ilele()
for _ in range(int(input())):
	(x, y) = ilele()
	Y(d <= x + y <= 2 * n - d and -d <= x - y <= d)


(n, d) = map(int, input().split())
m = int(input())
for _ in range(m):
	(x, y) = map(int, input().split())
	print('YES' if abs(x - y) <= d and abs(x + y - n) <= n - d else 'NO')


i = lambda : map(int, input().split())
(n, d) = i()
(m,) = i()
for _ in [0] * m:
	(x, y) = i()
	print('NYOE S'[-d <= x - y <= d and d <= x + y <= n + n - d::2])


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if (x - y <= d and x - y >= -d) and (x + y <= 2 * n - d and x + y >= d):
		print('Yes')
	else:
		print('No')


def check(n, d, x, y):
	ch = True
	if y < -x + d:
		ch = False
	if y < x - d:
		ch = False
	if y > x + d:
		ch = False
	if y > -x + 2 * n - d:
		ch = False
	return ch
(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if check(n, d, x, y):
		print('YES')
	else:
		print('NO')


def test_1():
	import math
	from collections import Counter
	(n, d) = list(map(int, input().split(' ')))
	m = list(map(int, input().split(' ')))[0]
	for i in range(m):
		(x, y) = list(map(int, input().split(' ')))
		if d <= x + y <= 2 * n - d and -1 * d <= x - y <= d:
			print('YES')
		else:
			print('NO')
test_1()


def inF(d, n, x, y):
	mg = 0.7071067811865475
	x1 = (x - y) * mg
	y1 = (x + y) * mg
	if x1 >= -d * mg and x1 <= d * mg:
		if y1 >= d * mg and y1 <= (2 * n - d) * mg:
			return True
	return False
(n, d) = list(map(int, input().split()))
m = int(input())
x = []
y = []
for i in range(m):
	(x1, y1) = list(map(int, input().split()))
	x.append(x1)
	y.append(y1)
for i in range(m):
	if inF(d, n, x[i], y[i]):
		print('YES')
	else:
		print('NO')


(n, d) = [int(i) for i in input().split()]
m = int(input())
a = []
for i in range(m):
	(x, y) = [int(i) for i in input().split()]
	if x + y < d or x + y > 2 * n - d or abs(x - y) > d:
		a.append('NO')
	else:
		a.append('YES')
for i in a:
	print(i)


def f(x1, y1, x2, y2, x, y):
	a = -(y2 - y1)
	b = x2 - x1
	c = -(a * x1 + b * y1)
	d = a * x + b * y + c
	return d
(n, d) = map(int, input().split())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
k = int(input())
for i in range(k):
	(x, y) = map(int, input().split())
	d = f(x2, y2, x1, y1, x, y)
	if d > 0:
		print('NO')
		continue
	d = f(x3, y3, x2, y2, x, y)
	if d > 0:
		print('NO')
		continue
	d = f(x4, y4, x3, y3, x, y)
	if d > 0:
		print('NO')
		continue
	d = f(x1, y1, x4, y4, x, y)
	if d > 0:
		print('NO')
		continue
	print('YES')


(n, d) = [int(i) for i in input().split()]
k0 = -1
k1 = 1
k2 = 1
k3 = -1
b0 = d
b1 = -d
b2 = d
b3 = n - d + n
m = int(input())
A = []
for _ in range(m):
	(x, y) = [int(i) for i in input().split()]
	if y >= k0 * x + b0 and y >= k1 * x + b1 and (y <= x * k2 + b2) and (y <= k3 * x + b3):
		A.append('YES')
	else:
		A.append('NO')
for i in A:
	print(i)


(n, d) = map(int, input().split())
m = int(input())
kuz = []
for i in range(m):
	(x, y) = map(int, input().split())
	kuz.append([x, y])
coords = [[0, d], [d, 0], [n, n - d], [n - d, n]]
for i in range(len(kuz)):
	if kuz[i][0] > d and kuz[i][1] < kuz[i][0] - d:
		print('NO')
	elif kuz[i][0] < d and kuz[i][1] < d - kuz[i][0]:
		print('NO')
	elif kuz[i][0] < n - d and max(n, d) - kuz[i][1] < n - d - kuz[i][0]:
		print('NO')
	elif kuz[i][0] > n - d and max(n, d) - kuz[i][1] < kuz[i][0] - (n - d):
		print('NO')
	else:
		print('YES')


(n, d) = map(int, input().split())

def f1(y, x):
	if x + d - y < 0:
		return -1
	else:
		return 1

def f2(y, x):
	if x - d - y > 0:
		return 1
	else:
		return -1

def f3(y, x):
	if y + x - d < 0:
		return -1
	else:
		return 1

def f4(y, x):
	if y + x + d - n * 2 > 0:
		return 1
	else:
		return -1
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if f1(y, x) + f2(y, x) + f3(y, x) + f4(y, x) == 0:
		print('yes')
	else:
		print('no')


q = tuple(map(int, input().split()))
n = q[0]
d = q[1]
m = int(input())
k = [0 for i in range(m)]
for i in range(m):
	k[i] = list(map(int, input().split()))
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
for i in range(m):
	if (x1 - k[i][0]) * (y2 - y1) - (x2 - x1) * (y1 - k[i][1]) == 0 or (x2 - k[i][0]) * (y3 - y2) - (x3 - x2) * (y2 - k[i][1]) == 0 or (x3 - k[i][0]) * (y1 - y3) - (x1 - x3) * (y3 - k[i][1]) == 0 or ((x1 - k[i][0]) * (y4 - y1) - (x4 - x1) * (y1 - k[i][1]) == 0) or ((x4 - k[i][0]) * (y3 - y4) - (x3 - x4) * (y4 - k[i][1]) == 0):
		print('YES')
		continue
	if (x1 - k[i][0]) * (y2 - y1) - (x2 - x1) * (y1 - k[i][1]) > 0 and (x2 - k[i][0]) * (y3 - y2) - (x3 - x2) * (y2 - k[i][1]) > 0 and ((x3 - k[i][0]) * (y1 - y3) - (x1 - x3) * (y3 - k[i][1]) > 0):
		print('YES')
		continue
	if (x1 - k[i][0]) * (y2 - y1) - (x2 - x1) * (y1 - k[i][1]) < 0 and (x2 - k[i][0]) * (y3 - y2) - (x3 - x2) * (y2 - k[i][1]) < 0 and ((x3 - k[i][0]) * (y1 - y3) - (x1 - x3) * (y3 - k[i][1]) < 0):
		print('YES')
		continue
	if (x1 - k[i][0]) * (y4 - y1) - (x4 - x1) * (y1 - k[i][1]) > 0 and (x4 - k[i][0]) * (y3 - y4) - (x3 - x4) * (y4 - k[i][1]) > 0 and ((x3 - k[i][0]) * (y1 - y3) - (x1 - x3) * (y3 - k[i][1]) > 0):
		print('YES')
		continue
	if (x1 - k[i][0]) * (y4 - y1) - (x4 - x1) * (y1 - k[i][1]) < 0 and (x4 - k[i][0]) * (y3 - y4) - (x3 - x4) * (y4 - k[i][1]) < 0 and ((x3 - k[i][0]) * (y1 - y3) - (x1 - x3) * (y3 - k[i][1]) < 0):
		print('YES')
		continue
	else:
		print('NO')


def is_in_triangle(x, y, z, p):
	(x1, y1) = x
	(x2, y2) = y
	(x3, y3) = z
	(x0, y0) = p
	a = (x1 - x0) * (y2 - y1) - (x2 - x1) * (y1 - y0)
	b = (x2 - x0) * (y3 - y2) - (x3 - x2) * (y2 - y0)
	c = (x3 - x0) * (y1 - y3) - (x1 - x3) * (y3 - y0)
	return a >= 0 and b >= 0 and (c >= 0) or (a <= 0 and b <= 0 and (c <= 0))
(n, d) = map(int, input().split())
m = int(input())
xp = (0, d)
yp = (d, 0)
zp = (n, n - d)
dp = (n - d, n)
for i in range(m):
	p1 = tuple(map(int, input().split()))
	if is_in_triangle(xp, yp, zp, p1) or is_in_triangle(xp, dp, zp, p1):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split(' '))
m = int(input())
outputs = []

def l1(a, b):
	if b <= a + d:
		return True
	else:
		return False

def l3(a, b):
	if b >= a - d:
		return True
	else:
		return False

def l2(a, b):
	if b >= -a + d:
		return True
	else:
		return False

def l4(a, b):
	if b <= -a + 2 * n - d:
		return True
	else:
		return False
for i in range(m):
	(x, y) = map(int, input().split(' '))
	if l1(x, y) and l2(x, y) and l3(x, y) and l4(x, y):
		outputs.append('YES')
	else:
		outputs.append('NO')
for x in outputs:
	print(x)


import sys
input = sys.stdin.buffer.readline
(n, d) = map(int, input().split())
m = int(input())
while m:
	m -= 1
	(x, y) = map(int, input().split())
	e1 = x + y - d
	e2 = x - y - d
	e3 = x + y - 2 * n + d
	e4 = y - d - x
	if e1 == 0 or e2 == 0 or e3 == 0 or (e4 == 0):
		print('YES')
	elif e1 > 0 and e2 < 0 and (e3 < 0) and (e4 < 0):
		print('YES')
	else:
		print('NO')


strr = input()
(n, d) = strr.split()
d = int(d)
n = int(n)
m = input()
m = int(m)
for i in range(m):
	strr = input()
	(a, b) = strr.split()
	x = int(a)
	y = int(b)
	boo = 0
	tong = x + y
	hieu = x - y
	if tong >= d:
		if tong > 2 * n - d:
			boo = 1
	else:
		boo = 1
	if hieu >= -d:
		if hieu > d:
			boo = 1
	else:
		boo = 1
	if boo == 0:
		print('YES')
	else:
		print('NO')


import math

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def dist(self, other):
		x = other.x - self.x
		y = other.y - self.y
		return math.hypot(x, y)

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def print(self):
		print(self.x, self.y)

class Vector:

	def __init__(self, begin=Point(0, 0), end=Point(0, 0)):
		self.x = end.x - begin.x
		self.y = end.y - begin.y
		self.begin = begin
		self.end = end

	def scalar(self, other):
		return other.x * self.x + other.y * self.y

	def product(self, other):
		return self.x * other.y - self.y * other.x

	def lenght(self):
		return math.hypot(self.x, self.y)

	def __add__(self, other):
		buff = Vector()
		buff.y = self.y + other.y
		buff.x = self.x + other.x
		return buff

	def __mul__(self, k):
		buff = self
		buff.y *= k
		buff.x *= k
		return buff

	def atan2(self, other):
		return math.atan2(self.product(other), self.scalar(other))

class Line:

	def __init__(self, one, two):
		self.a = two.y - one.y
		self.b = one.x - two.x
		self.c = one.y * (two.x - one.x) - self.a * one.x
		self.begin = one
		self.end = two

	def lenght(self):
		x = self.end.x - self.begin.x
		y = self.end.y - self.begin.y
		return math.hypot(x, y)

	def point_in_line(self, other):
		A = Vector(self.begin, other)
		B = Vector(self.begin, self.end)
		if abs(B.product(A)) <= 1e-06:
			return True
		return False

	def point_in_ray(self, other):
		A = Vector(self.begin, other)
		B = Vector(self.begin, self.end)
		if abs(B.product(A)) <= 1e-06 and B.scalar(A) >= 0:
			return True
		return False

	def point_in_section(self, other):
		A = Vector(self.begin.x, other)
		B = Vector(self.begin, self.end)
		if abs(B.product(A)) <= 1e-06 and B.scalar(A) >= 0 and (B.lenght() >= A.lenght()):
			return True
		return False

	def dist_point_to_line(self, other):
		A = Vector(self.begin, other)
		B = Vector(self.begin, self.end)
		if B.lenght() != 0:
			return abs(A.product(B)) / B.lenght()
		else:
			return other.dist(self.begin)

	def dist_point_to_ray(self, other):
		A = Vector(self.begin, other)
		B = Vector(self.begin, self.end)
		if A.scalar(B) >= 0:
			return self.dist_point_to_line(other)
		return self.begin.dist(other)

	def dist_point_to_section(self, other):
		A1 = Vector(self.begin, other)
		B1 = Vector(self.begin, self.end)
		A2 = Vector(self.end, other)
		B2 = Vector(self.end, self.begin)
		if A1.scalar(B1) >= 0 and A2.scalar(B2) >= 0:
			return self.dist_point_to_line(other)
		return min(self.begin.dist(other), self.end.dist(other))

	def check_two_points_is_between(self, one, two):
		Main = Vector(self.begin, self.end)
		A = Vector(self.begin, one)
		B = Vector(self.begin, two)
		check1 = Main.product(A)
		check2 = Main.product(B)
		if check1 >= -1000000.0 and check2 <= 1e-06 or (check1 <= 1e-06 and check2 >= -1e-06):
			return True
		return False

	def enter_with_section(self, other):
		A = self.check_two_points_is_between(other.begin, other.end)
		B = other.check_two_points_is_between(self.begin, self.end)
		if A == True and B == True:
			return True
		return False

	def dist_with_section(self, other):
		if self.enter_with_section(other):
			return 0
		else:
			a = self.dist_point_to_section(other.begin)
			b = self.dist_point_to_section(other.end)
			c = other.dist_point_to_section(self.begin)
			d = other.dist_point_to_section(self.begin)
			return min(a, b, c, d)

	def get_normal(self):
		a = Vector()
		if self.lenght() != 0:
			a.x = self.a / self.lenght()
			a.y = self.b / self.lenght()
		return a

	def get_cord_base_normal(self, other):
		dist = self.dist_point_to_line(other)
		k = dist / self.get_normal().lenght()
		A = other + self.get_normal() * k
		B = other - self.get_normal() * k
		if self.point_in_line(A):
			return A
		return B

	def get_cord_enter_with_section(self, other):
		if self.enter_with_section(other):
			if self.b != 0 and other.b != 0:
				k1 = self.a / self.b
				b1 = self.c / self.b
				k2 = other.a / other.b
				b2 = other.c / other.b
				x = (b2 - b1) / (k1 - k2)
				y = x * k1 + b1
				return Point(x, y)
		return None

class Circle:

	def __init__(self, begin, r):
		self.begin = begin
		self.r = r

	def area(self):
		return math.pi * self.r ** 2
(n, d) = map(int, input().split())
a1 = Point(0, d)
a2 = Point(d, 0)
a3 = Point(n, n - d)
a4 = Point(n - d, n)
arr = [Vector(a1, a2), Vector(a2, a3), Vector(a3, a4), Vector(a4, a1)]
k = int(input())
for i in range(k):
	flag = True
	(a, b) = map(int, input().split())
	for j in arr:
		c = Vector(j.begin, Point(a, b))
		if j.product(c) < 0:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


(n, d) = input().split()
n = int(n)
d = int(d)
rect = [[0, d], [d, 0], [n, n - d], [n - d, n]]
m = int(input())
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + n + n - d):
		print('YES')
	else:
		print('NO')


def inside(point, n, d):
	x = point[0]
	y = point[1]
	if 2 * n - d >= x + y >= d and d >= x - y >= -d:
		return True
	else:
		return False
(n, d) = map(int, input().split())
for i in range(int(input())):
	pt = [int(j) for j in input().split()]
	if inside(pt, n, d):
		print('YES')
	else:
		print('NO')


def check(x, y):
	return x + y >= d and x - y <= d and (y - x <= d) and (x + y <= 2 * n - d)
(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if check(x, y):
		print('YES')
	else:
		print('NO')


class Node:
	x = 0.0
	y = 0.0

	def __init__(self, x, y):
		self.x = x
		self.y = y

class InOrOut:
	esp = 0.001
	coor = []

	def __init__(self):
		(n, m) = [float(i) for i in input().split(' ')]
		self.n = n
		self.m = m
		self.coor.append(Node(0, m))
		self.coor.append(Node(m, 0))
		self.coor.append(Node(n, n - m))
		self.coor.append(Node(n - m, n))

	def get_len(self, node1, node2):
		ans = ((node1.x - node2.x) ** 2 + (node1.y - node2.y) ** 2) ** 0.5
		return ans

	def get_s(self, node1, node2, node3):
		len1 = self.get_len(node1, node2)
		len2 = self.get_len(node1, node3)
		len3 = self.get_len(node2, node3)
		p = (len1 + len2 + len3) / 2.0
		s = (p * abs(p - len1) * abs(p - len2) * abs(p - len3)) ** 0.5
		return s

	def if_equal(self):
		are = self.get_len(self.coor[0], self.coor[1]) * self.get_len(self.coor[0], self.coor[3])
		q = int(input())
		for i in range(0, q):
			(x1, y1) = [float(i) for i in input().split(' ')]
			now = Node(x1, y1)
			ss = 0.0
			for k in range(0, 4):
				k2 = (k + 1) % 4
				ss += self.get_s(now, self.coor[k], self.coor[k2])
			cha = ss - are
			if cha < 0:
				cha = -cha
			if cha > self.esp:
				print('NO')
			else:
				print('YES')
temp = InOrOut()
temp.if_equal()


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	(t1, t2, t3, t4) = (False, False, False, False)
	if x + y >= d:
		t1 = True
	if y + n - x >= n - d:
		t2 = True
	if x + n - y >= n - d:
		t3 = True
	if n - x + n - y >= d:
		t4 = True
	if t1 and t2 and t3 and t4:
		print('YES')
	else:
		print('NO')


def input_ints():
	return list(map(int, input().split()))

def solve():
	(n, d) = input_ints()
	m = int(input())
	for i in range(m):
		(x, y) = input_ints()
		if d <= x + y <= 2 * n - d and -d <= y - x <= d:
			print('YES')
		else:
			print('NO')
solve()


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import stdin
(n, d) = arr_inp()
for i in range(int(input())):
	(x, y) = arr_inp()
	(mi, ma) = (d - x, n - d)
	if x > d:
		mi = x - d
	if x <= ma:
		ma = d + x
	else:
		ma = n - (x - ma)
	print('YES' if y >= mi and y <= ma else 'NO')


(n, d) = map(int, input().split())
m = int(input())
a = []
for i in range(m):
	xy = list(map(int, input().split()))
	a.append(xy)
for i in range(len(a)):
	xi = a[i][0]
	yi = a[i][1]
	if yi <= xi + d and yi <= -xi + 2 * n - d and (yi >= xi - d) and (yi >= -xi + d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	a = True
	(x, y) = map(int, input().split())
	if x - y > d or x - y < -d:
		a = False
	if x + y < d or x + y > 2 * n - d:
		a = False
	if a:
		print('Yes')
	else:
		print('No')


pole = input().split()
n = int(pole[0])
d = int(pole[1])
pervayakoord = [0, d]
vtorayakoord = [d, 0]
tretiyakoord = [n, n - d]
chetvkoord = [n - d, n]
kolvo_kuzn_in_pole = 0
kuzn_vsego = int(input())
for i in range(kuzn_vsego):
	vvod = input().split()
	x = int(vvod[0])
	y = int(vvod[1])
	if y <= x + d and y <= -x + (2 * n - d) and (y >= x - d) and (y >= -x + d):
		print('YES')
	else:
		print('NO')


(k, d) = map(int, input().split())
p = int(input())
for _ in range(p):
	(xi, yi) = map(int, input().split())
	print('YES' if abs(xi + yi) >= d and abs(xi + yi) <= 2 * k - d and (abs(xi - yi) <= d) else 'NO')


class Vec:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __sub__(self, other):
		return Vec(self.x - other.x, self.y - other.y)

	def __add__(self, other):
		return Vec(self.x + other.x, self.y + other.y)

	def __mod__(self, other):
		return self.x * other.y - self.y * other.x
(n, d) = map(int, input().split())
m = int(input())
c = [[int(e) for e in input().split()] for i in range(m)]
(pa, pb, pc, pd) = (Vec(d, 0), Vec(n, n - d), Vec(n - d, n), Vec(0, d))
(ab, bc, cd, da) = (pb - pa, pc - pb, pd - pc, pa - pd)
for (x, y) in c:
	p = Vec(x, y)
	(ap, bp, cp, dp) = (p - pa, p - pb, p - pc, p - pd)
	if ab % ap >= 0 and bc % bp >= 0 and (cd % cp >= 0) and (da % dp >= 0):
		print('YES')
	else:
		print('NO')


stroke = input()
(n, d) = map(int, stroke.split())
m = int(input())
listk = []
for i in range(m):
	stroke = input()
	(x, y) = map(int, stroke.split())
	k = {'x': x, 'y': y}
	listk.append(k)
for i in range(len(listk)):
	(xi, yi) = (listk[i]['x'], listk[i]['y'])
	if yi > xi + d:
		print('NO')
		continue
	if yi < -xi + d:
		print('NO')
		continue
	if yi > -xi + 2 * n - d:
		print('NO')
		continue
	if yi < xi - d:
		print('NO')
		continue
	print('YES')


s = input()
tmp = s.split(' ')
n = int(tmp[0])
d = int(tmp[1])
m = int(input())
chords = []
for i in range(m):
	chords.append(input())
for i in chords:
	res = 'NO'
	x = int(i.split(' ')[0])
	y = int(i.split(' ')[1])
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + 2 * n - d):
		res = 'YES'
	print(res)


(n, d) = map(int, input().split())
k = int(input())
maxx = 2 * n - d
minn = d
for i in range(k):
	(x, y) = map(int, input().split())
	if abs(x - y) <= d and x + y <= maxx and (x + y >= minn):
		print('YES')
	else:
		print('NO')


(n, d) = list(map(int, input().split()))
m = int(input())
s = []
for i in range(m):
	(x, y) = list(map(int, input().split()))
	if y >= d - x and y >= x - d and (y <= 2 * n - d - x) and (y <= x + d):
		s.append('YES')
	else:
		s.append('NO')
for i in s:
	print(i)


(p, n) = map(int, input().split())
a = int(input())
c = max(p, n)
d = min(p, n)
lists = [[] for i in range(2 * a)]
j = 0
while j < 2 * a:
	(lists[j], lists[j + 1]) = map(int, input().split())
	j = j + 2
k = 0
while k < 2 * a:
	if lists[k] + lists[k + 1] >= d and lists[k] + lists[k + 1] <= 2 * c - d and (lists[k] - lists[k + 1] <= d) and (lists[k + 1] - lists[k] <= d):
		print('YES')
	else:
		print('NO')
	k = k + 2


(n, d) = map(int, input().split())
k = int(input())
(r1, r2) = (d, 2 * n - d)
(r3, r4) = (-1 * d, d)
ans = []
for i in range(k):
	(x, y) = map(int, input().split())
	if x + y >= r1 and x + y <= r2 and (x - y >= r3) and (x - y <= r4):
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


from sys import stdin
stack = []
(n, d) = [int(x) for x in input().split()]
m = int(input())
for i in range(m):
	(x, y) = [int(x) for x in input().split()]
	if x + y - d >= 0 and x - y - d <= 0 and (x + y - 2 * n + d <= 0) and (x - y + d >= 0):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
answers = []
for i in range(m):
	(x, y) = map(int, input().split())
	if x + y >= d and x + y <= 2 * n - d:
		if abs(y - x) <= d:
			answers.append('YES')
		else:
			answers.append('NO')
	else:
		answers.append('NO')
for answer in answers:
	print(answer)


(n, d) = map(int, input().split())
m = int(input())
arr = [list(map(int, input().split())) for _ in range(m)]
for (x, y) in arr:
	if x < d and y < d and (y < d - x):
		print('NO')
		continue
	if x < n - d and y > d and (y > x + d):
		print('NO')
		continue
	if x > n - d and y > n - d and (y > 2 * n - d - x):
		print('NO')
		continue
	if x > d and y < n - d and (y < x - d):
		print('NO')
		continue
	print('YES')


(a, b) = map(int, input().split())
n = int(input())
for i in range(n):
	(x1, y1) = map(int, input().split())
	if 2 * a - b - y1 >= x1 >= abs(b - y1) and 2 * a - b - x1 >= y1 >= abs(b - x1):
		print('YES')
	else:
		print('NO')


nd = list(input())
n = ''
d = ''
for i in nd:
	if i == ' ':
		break
	n += i
nd = nd[::-1]
for i in nd:
	if i == ' ':
		break
	d += i
	d = d[::-1]
d = int(d)
n = int(n)
diap = n + n - d
otvet = []
kk = int(input())
for i in range(kk):
	k = list(input())
	kn = ''
	kd = ''
	for i in k:
		if i == ' ':
			break
		kn += i
	k = k[::-1]
	for i in k:
		if i == ' ':
			break
		kd += i
	kd = kd[::-1]
	kd = int(kd)
	kn = int(kn)
	kdiap = kn + kd
	test = abs(kd - kn)
	if kdiap <= diap and kdiap >= d and (kd <= n) and (kn <= n) and (test <= d):
		otvet.append('YES')
	else:
		otvet.append('NO')
for i in otvet:
	print(i)


I = lambda : map(int, input().split())
(n, d) = I()
for _ in range(int(input())):
	(x, y) = I()
	print(('NO', 'YES')[max(x - d, d - x) <= y <= min(x + d, 2 * n - d - x)])


(n, d) = [int(x) for x in input().split()]
m = int(input())

def ch(n, d, x, y):
	if n - y + x >= n - d and x + y >= d and (n - x + y >= n - d) and (n - x + n - y >= d):
		return True
	else:
		return False
for i in range(0, m):
	(x, y) = [int(j) for j in input().split()]
	if ch(n, d, x, y):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if y <= d:
		if y >= -1 * x + d and y >= x - d and (x <= n) and (y <= -1 * x + 2 * n - d if d > n - d else 1):
			print('YES')
		else:
			print('NO')
	elif n >= y > d:
		if y <= x + d and y <= -1 * x + 2 * n - d and (x <= n) and (y >= x - d):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


(n, d) = [int(i) for i in input().split()]
m = int(input())
k = [[int(i) for i in input().split()] for j in range(m)]

def check(x, y):
	s = x + y
	if x > n or y > n:
		return 'NO'
	elif d >= n - d and (s < d or s > n + (n - d)):
		return 'NO'
	elif x <= d and s >= d and (s <= d + x * 2):
		return 'YES'
	elif x > d and x < n - d and (s >= d + (x - d) * 2) and (s <= d + x * 2):
		return 'YES'
	elif x >= n - d and s >= d + (x - d) * 2 and (s <= d + (n - d) * 2):
		return 'YES'
	else:
		return 'NO'
res = [print(check(*i)) for i in k]


(n, d) = input().split()
n = int(n)
d = int(d)
k = int(input())
m = []
for i in range(k):
	m.append([int(j) for j in input().split()])

def y1(x):
	return -x + d

def y2(x):
	return x + d

def y3(x):
	return -x + 2 * n - d

def y4(x):
	return x - d
if 2 * d ** 2 < 2 * (n - d) ** 2:
	for i in range(k):
		if m[i][0] < d:
			if y1(m[i][0]) <= m[i][1] <= y2(m[i][0]):
				print('YES')
			else:
				print('NO')
		elif d <= m[i][0] <= n - d:
			if y4(m[i][0]) <= m[i][1] <= y2(m[i][0]):
				print('YES')
			else:
				print('NO')
		elif n - d < m[i][0] <= n:
			if y4(m[i][0]) <= m[i][1] <= y3(m[i][0]):
				print('YES')
			else:
				print('NO')
elif 2 * d ** 2 > 2 * (n - d) ** 2:
	for i in range(k):
		if m[i][0] < n - d:
			if y1(m[i][0]) <= m[i][1] <= y2(m[i][0]):
				print('YES')
			else:
				print('NO')
		elif n - d <= m[i][0] <= d:
			if y1(m[i][0]) <= m[i][1] <= y3(m[i][0]):
				print('YES')
			else:
				print('NO')
		elif d < m[i][0] <= n:
			if y4(m[i][0]) <= m[i][1] <= y3(m[i][0]):
				print('YES')
			else:
				print('NO')
elif 2 * d ** 2 == 2 * (n - d) ** 2:
	for i in range(k):
		if m[i][0] <= d:
			if y1(m[i][0]) <= m[i][1] <= y2(m[i][0]):
				print('YES')
			else:
				print('NO')
		elif d < m[i][0] <= n:
			if y4(m[i][0]) <= m[i][1] <= y3(m[i][0]):
				print('YES')
			else:
				print('NO')


a = [int(s) for s in input().split(' ')]
m = int(input())
for i in range(m):
	b = [int(q) for q in input().split(' ')]
	if b[1] >= -b[0] + a[1] and b[1] >= b[0] - a[1] and (b[1] <= -b[0] + 2 * a[0] - a[1]) and (b[1] <= b[0] + a[1]):
		print('YES')
	else:
		print('NO')


(d, a) = map(int, input().split())
m = int(input())
i = 0
zuobiaos = []
running = True
while running:
	if i == m:
		running = False
	else:
		(x, y) = map(int, input().split())
		i = i + 1
		if x + y >= min(d, a) and x + y <= 2 * max(d, a) - min(d, a) and (x + min(d, a) >= y) and (y + min(d, a) >= x):
			zuobiaos.append('YES')
		else:
			zuobiaos.append('NO')
for zuobiao in zuobiaos:
	print(zuobiao)


(n, d) = list(map(int, input().split()))
r = int(input())
for i in range(r):
	(x, y) = list(map(int, input().split()))
	if -x - y + d <= 0 and -x - y + 2 * n - d >= 0 and (x + d - y >= 0) and (x - d - y <= 0):
		print('YES')
	else:
		print('NO')


(n, d) = list(map(int, input().split()))
m = int(input())
k = 1
while k <= m:
	(x0, y0) = list(map(int, input().split()))
	if y0 <= x0 + d and y0 >= x0 - d and (y0 >= -x0 + d) and (y0 <= -x0 + 2 * n - d):
		print('YES')
	else:
		print('NO')
	k += 1


cor = input()
cor = cor.split(' ')
cor[0] = int(cor[0])
cor[1] = int(cor[1])
cuz = int(input())
a = [[0 for i in range(2)] for j in range(cuz)]
for i in range(cuz):
	l = input()
	l = l.split(' ')
	l[0] = int(l[0])
	l[1] = int(l[1])
	a[i][0] = l[0]
	a[i][1] = l[1]
for i in range(cuz):
	if a[i][0] + a[i][1] - cor[1] >= 0 and a[i][0] - a[i][1] + cor[1] >= 0 and (a[i][0] + a[i][1] - 2 * cor[0] + cor[1] <= 0) and (a[i][0] - a[i][1] - cor[1] <= 0):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())

def line1(a, b):
	if b >= a - d:
		return True
	return False

def line2(a, b):
	if b <= a + d:
		return True
	return False

def line3(a, b):
	if b >= d - a:
		return True
	return False

def line4(a, b):
	if b <= 2 * n - d - a:
		return True
	return False
for i in range(m):
	(a, b) = map(int, input().split())
	if line1(a, b) and line2(a, b) and line3(a, b) and line4(a, b):
		print('YES')
	else:
		print('NO')


(n, d) = input().split()
n = int(n)
d = int(d)
m = int(input())

def sign(x):
	if x > 0:
		return 1
	elif x == 0:
		return 0
	else:
		return -1

def func(x0, y0, x1, y1, x2, y2, x3, y3):
	a = (x1 - x0) * (y2 - y1) - (x2 - x1) * (y1 - y0)
	b = (x2 - x0) * (y3 - y2) - (x3 - x2) * (y2 - y0)
	c = (x3 - x0) * (y1 - y3) - (x1 - x3) * (y3 - y0)
	if sign(a) == sign(b) == sign(c) or sign(a) == 0 or sign(b) == 0 or (sign(c) == 0):
		return True
	else:
		return False
kuz = []
for i in range(m):
	pos = input().split()
	x = int(pos[0])
	y = int(pos[1])
	if func(x, y, 0, d, d, 0, n, n - d) or func(x, y, 0, d, n - d, n, n, n - d):
		kuz.append('YES')
	else:
		kuz.append('NO')
for i in kuz:
	print(i)


def y1(x, d):
	return x + d

def y2(x, d):
	return x - d

def y3(x, d):
	return d - x

def y4(x, n, d):
	return 2 * n - d - x

def answer(x, y, n, d):
	if y1(x, d) >= y and y2(x, d) <= y and (y3(x, d) <= y) and (y4(x, n, d) >= y):
		return 'YES'
	return 'NO'
(n, d) = map(int, input().split())
m = int(input())
for q in range(m):
	array = [int(i) for i in input().split()]
	print(answer(array[0], array[1], n, d))


import math

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
(n, d) = get_int_vector()
m = int(input())
for _ in range(m):
	(x, y) = get_int_vector()
	if y + x - d >= 0 and y + x - 2 * n + d <= 0 and (y - x + d >= 0) and (y - x - d <= 0):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
c = [list(map(int, input().split())) for _ in range(m)]
for p in c:
	(x, y) = p
	if x + y >= d and x + y <= 2 * n - d and (x - y <= d) and (x - y >= -d):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def myfunction(x, y, n, d):
	if y + x >= d and y + x <= 2 * n - d and (x - y <= d) and (y - x <= d):
		return 'YES\n'
	else:
		return 'NO\n'
(n, d) = list(map(int, stdin.readline().split()))
m = int(stdin.readline())
for i in range(m):
	(x, y) = list(map(int, stdin.readline().split()))
	stdout.write(myfunction(x, y, n, d))


(n, d) = map(int, input().split())
N = int(input())
for i in range(N):
	(x, y) = map(int, input().split())
	if x + y >= d and x + y <= n + n - d and (x + y >= d) and (abs(x - y) <= d):
		print('YES')
	else:
		print('NO')


arr = input().split(' ')
n = int(arr[0])
d = int(arr[1])
m = int(input())
arr = []
for i in range(0, m):
	arr.append(input().split(' '))
	arr[i][0] = int(arr[i][0])
	arr[i][1] = int(arr[i][1])

def isLeft(x, y):
	return y <= -1 * x + 2 * n - d

def isRight(x, y):
	return y >= -1 * x + d

def isUp(x, y):
	return y >= x - d

def isDown(x, y):
	return y <= x + d

def inField(x, y):
	return isDown(x, y) and isLeft(x, y) and isRight(x, y) and isUp(x, y)
for i in range(0, arr.__len__()):
	if inField(arr[i][0], arr[i][1]):
		print('YES')
	else:
		print('NO')


(n, d) = [int(x) for x in input().split()]
m = [int(x) for x in input().split()][0]

def testField(x, y):
	if y - x > d or x - y > d or x + y < d or (x + y > 2 * n - d):
		return 'NO'
	else:
		return 'YES'
for i in range(m):
	(x, y) = [int(x) for x in input().split()]
	print(testField(x, y))


(n, d) = map(int, input().split())
(_x1, _x2) = (min(d, -d), max(d, -d))
(_y1, _y2) = (min(d, 2 * n - d), max(d, 2 * n - d))
k = int(input())
for i in range(k):
	(x, y) = map(int, input().split())
	(_x, _y) = (y - x, y + x)
	if _x >= _x1 and _x <= _x2 and (_y >= _y1) and (_y <= _y2):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for _ in range(m):
	(x, y) = map(int, input().split())
	if x - d <= y <= x + d and d - y <= x <= 2 * n - d - y:
		print('yes')
	else:
		print('no')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def borderinside_1(x, y, n, d):
	a = -d
	b = x + y - d
	if (a >= 0) ^ (b < 0) == 0:
		return 1
	else:
		return 0

def borderinside_2(x, y, n, d):
	a = -2 * n + d
	b = x + y - 2 * n + d
	if b == 0:
		b = -1
	if (a >= 0) ^ (b < 0) == 0:
		return 0
	else:
		return 1

def borderinside_3(x, y, n, d):
	a = d
	b = y - x + d
	if (a >= 0) ^ (b < 0) == 0:
		return 0
	else:
		return 1

def borderinside_4(x, y, n, d):
	a = +d
	b = x - y + d
	if (a >= 0) ^ (b < 0) == 0:
		return 0
	else:
		return 1

def check_inside(n, d, gr_x, gr_y):
	check_side1 = borderinside_1(gr_x, gr_y, n, d)
	check_side2 = borderinside_2(gr_x, gr_y, n, d)
	check_side3 = borderinside_3(gr_x, gr_y, n, d)
	check_side4 = borderinside_4(gr_x, gr_y, n, d)
	if check_side4 & check_side3 & check_side2 & check_side1 == 1:
		print('YES')
	else:
		print('NO')
	return 0
borders = inlt()
if borders[0] > borders[1]:
	n = borders[0]
	d = borders[1]
else:
	d = borders[0]
	n = borders[1]
num_points = inp()
for x in range(0, num_points):
	grasshopper = inlt()
	grasshopper_x = int(grasshopper[0])
	grasshopper_y = int(grasshopper[1])
	check_inside(n, d, grasshopper_x, grasshopper_y)


(n, d) = map(int, input().split())
kol = int(input())

def yesno(xp, yp, x1, y1, x2, y2):
	a = -y2 + y1
	b = x2 - x1
	c = -(a * x1 + b * y1)
	e = a * xp + b * yp + c
	if e > 0:
		return False
	else:
		return True
for i in range(kol):
	(xp, yp) = map(int, input().split())
	ans = []
	ans.append(yesno(xp, yp, 0, d, n - d, n))
	ans.append(yesno(xp, yp, n - d, n, n, n - d))
	ans.append(yesno(xp, yp, n, n - d, d, 0))
	ans.append(yesno(xp, yp, d, 0, 0, d))
	if False in ans:
		print('NO')
	else:
		print('YES')


def rs():
	return input().strip()

def ri():
	return int(input())

def ria():
	return list(map(int, input().split()))

def ia_to_s(a):
	return ' '.join([str(s) for s in a])

def solve(n, d, x, y):
	return y >= -x + d and y <= -x + 2 * n - d and (y <= x + d) and (y >= x - d)

def main():
	(n, d) = ria()
	m = ri()
	for i in range(m):
		(x, y) = ria()
		print('YES' if solve(n, d, x, y) else 'NO')
main()


(n, d) = map(int, input().split())
m = int(input())
for _ in range(m):
	(x, y) = map(int, input().split())
	ok = True
	if not (x - y <= d and x - y >= -d):
		ok = False
	if not (x + y <= n + n - d and x + y >= d):
		ok = False
	if ok:
		print('YES')
	else:
		print('NO')


(n, d) = [int(x) for x in input().split()]
for i in range(int(input())):
	(i, j) = [int(x) for x in input().split()]
	if abs(i - j) <= d and abs(i + j - n) <= n - d:
		print('yes')
	else:
		print('no')


def is_in(x, y):
	global n, d, xs
	(a, b) = xs[x]
	return a >= y >= b
(n, d) = map(int, input().split())
m = int(input())
xs = dict()
(a, b) = (d - 1, d + 1)
for i in range(0, n + 1):
	a += 1
	na = a
	if a > n:
		na = n - a % n
	b -= 1
	nb = abs(b)
	xs[i] = (na, nb)
for i in range(m):
	(x, y) = map(int, input().split())
	if is_in(x, y):
		print('YES')
	else:
		print('NO')


(n, d) = input().split()
(n, d) = (int(n), int(d))
k = int(input())
for i in range(k):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if a + d >= b and 2 * n - d - a >= b and (a - d <= b) and (d - a <= b):
		print('yes')
	else:
		print('no')


(n, d) = map(int, input().split())
t = int(input())
k2 = [[0] * 2 for i in range(n + 1)]
ma = d
mi = d
p = 0
p1 = 0
for i in range(n + 1):
	if i == 0:
		k2[0][1] = d
		k2[0][0] = d
	elif i == n:
		k2[i][1] = n - d
		k2[i][0] = n - d
	else:
		if ma == n or p == 1:
			ma -= 1
			p = 1
		else:
			ma += 1
			p = 0
		if mi == 0 or p1 == 1:
			mi += 1
			p1 = 1
		else:
			mi -= 1
			p1 = 0
		k2[i][1] = mi
		k2[i][0] = ma
for i in range(t):
	(x, y) = map(int, input().split())
	if k2[x][0] >= y and k2[x][1] <= y:
		print('YES')
	else:
		print('NO')


def inside(x, y, n, d):
	if (x - y + d) * (x - y - d) * (x + y - d) * (x + y - n * 2 + d) >= 0:
		print('YES')
	else:
		print('NO')
(n, d) = list(map(int, input().strip().split()))
m = int(input())
a = []
for j in range(m):
	a.append(list(map(int, input().strip().split())))
	inside(a[j][0], a[j][1], n, d)


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	f = 1
	if not (x - y <= d and x - y >= -d):
		f = 0
	if not (x + y <= n + n - d and x + y >= d):
		f = 0
	if f == 1:
		print('YES')
	else:
		print('NO')


f1 = input()
n1 = 2
(n, d) = (0, 0)
for i in map(int, f1.split()):
	n1 = n1 - 1
	if n1 >= 0 and n1 == 1:
		n = i
	elif n1 == 0:
		d = i
m = int(input())
(x, y) = (0, 0)
z = [0] * m
for j in range(0, m):
	a = input()
	n1 = 2
	(x, y) = (0, 0)
	for i in map(int, a.split()):
		n1 = n1 - 1
		if n1 >= 0 and n1 == 1:
			x = i
		elif n1 == 0:
			y = i
	if y >= d - x and y >= x - d and (y <= x + d) and (y <= n - d + n - x):
		z[j] = 1
	else:
		z[j] = 0
for i in range(0, m):
	if z[i] == 1:
		print('YES')
	else:
		print('NO')


import math
k = input().split(' ')
q = int(input())
lis = []
for oo in range(q):
	lis.append(input())
n = int(k[0])
d = int(k[1])
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
b = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
c = ((x3 - x4) ** 2 + (y3 - y4) ** 2) ** 0.5
d = ((x4 - x1) ** 2 + (y4 - y1) ** 2) ** 0.5
s = a * b
for pp in range(q):
	x5 = int(lis[pp].split(' ')[0])
	y5 = int(lis[pp].split(' ')[1])
	r1 = ((x1 - x5) ** 2 + (y1 - y5) ** 2) ** 0.5
	r2 = ((x2 - x5) ** 2 + (y2 - y5) ** 2) ** 0.5
	r3 = ((x3 - x5) ** 2 + (y3 - y5) ** 2) ** 0.5
	r4 = ((x4 - x5) ** 2 + (y4 - y5) ** 2) ** 0.5
	p1 = (a + r1 + r2) / 2
	s1 = (p1 * (p1 - a) * (p1 - r1) * (p1 - r2)) ** 0.5
	p2 = (b + r2 + r3) / 2
	s2 = (p2 * (p2 - b) * (p2 - r3) * (p2 - r2)) ** 0.5
	p3 = (c + r3 + r4) / 2
	s3 = (p3 * (p3 - c) * (p3 - r3) * (p3 - r4)) ** 0.5
	p4 = (d + r4 + r1) / 2
	s4 = (p4 * (p4 - d) * (p4 - r1) * (p4 - r4)) ** 0.5
	try:
		if abs(s - (s1 + s2 + s3 + s4)) < 0.01:
			print('YES')
		else:
			print('NO')
	except:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x1, y1) = map(int, input().split())
	if x1 + y1 < d or x1 + y1 > 2 * n - d or x1 + (n - y1) < n - d or (n - x1 + y1 < n - d):
		print('NO')
	else:
		print('YES')


def pr(x, y):
	fl = False
	if (x - xx[0]) * (yy[3] - yy[0]) >= (y - yy[0]) * (xx[3] - xx[0]):
		fl = True
	if (x - xx[0]) * (yy[1] - yy[0]) <= (y - yy[0]) * (xx[1] - xx[0]) and fl:
		fl = True
	else:
		fl = False
	if (x - xx[1]) * (yy[2] - yy[1]) <= (y - yy[1]) * (xx[2] - xx[1]) and fl:
		fl = True
	else:
		fl = False
	if (x - xx[2]) * (yy[3] - yy[2]) <= (y - yy[2]) * (xx[3] - xx[2]) and fl:
		return 'YES'
	return 'NO'
(n, d) = map(int, input().split())
a = [0, d, d, 0, n, n - d, n - d, n]
xx = a[::2]
k = int(input())
yy = a[1::2]
for i in range(k):
	(x1, y1) = map(int, input().split())
	print(pr(x1, y1))


(n, d) = map(int, input().split())
m = int(input())
kuz = []
for i in range(m):
	(x, y) = map(int, input().split())
	if x + y >= d and x - y <= d and (y - x <= d) and (x + y <= n + (n - d)):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
k = []
for i in range(m):
	k.append(list(map(int, input().split())))
ans = [0] * m
up = d
down = d
if n - d >= d:
	for x in range(n + 1):
		for i in range(m):
			if k[i][0] == x and down <= k[i][1] <= up:
				ans[i] = 1
		if x < min(n - d, d):
			up += 1
			down -= 1
		elif x < n - min(n - d, d):
			up += 1
			down += 1
		else:
			up -= 1
			down += 1
else:
	for x in range(n + 1):
		for i in range(m):
			if k[i][0] == x and down <= k[i][1] <= up:
				ans[i] = 1
		if x < min(n - d, d):
			up += 1
			down -= 1
		elif x < n - min(n - d, d):
			up -= 1
			down -= 1
		else:
			up -= 1
			down += 1
for i in ans:
	if i:
		print('YES')
	else:
		print('NO')


(n, d) = list(map(int, input().split()))
k = int(input())
anss = []
for kuzn in range(k):
	(x, y) = list(map(int, input().split()))
	if x - d <= y <= x + d and -x + d <= y <= -x + 2 * n - d:
		anss.append('YES')
	else:
		anss.append('NO')
for ans in anss:
	print(ans)


(n, d) = [int(x) for x in input().split(' ')]
k = int(input())
res = []
for kk in range(k):
	(x, y) = [int(x) for x in input().split(' ')]
	topleft = y <= x + d
	botright = y >= x - d
	botleft = y >= -x + d
	topright = y <= -x + n + (n - d)
	res.append('YES' if topleft and botright and botleft and topright else 'NO')
for r in res:
	print(r)


(n, d) = map(int, input().split())
for i in range(int(input())):
	(x2, y2) = map(int, input().split())
	if x2 + y2 < d or x2 + y2 > 2 * n - d or x2 + (n - y2) < n - d or (n - x2 + y2 < n - d):
		print('NO')
	else:
		print('YES')


inp = input().split()
n = float(inp[0])
d = float(inp[1])
m = int(input())
for i in range(m):
	tmp = input().split()
	(x, y) = (float(tmp[0]), float(tmp[1]))
	if y >= -x + d and y >= x - d and (y <= x + d) and (y <= -x + 2 * n - d):
		print('YES')
	else:
		print('NO')


from math import sqrt

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

class Vector:

	def __init__(self, x1, y1, x2, y2):
		self.x1 = x1
		self.y1 = y1
		self.x2 = x2
		self.y2 = y2

	def count(self):
		return sqrt((self.x2 - self.x1) ** 2 + (self.y2 - self.y1) ** 2)

class Square:

	def __init__(self, x1, y1, x2, y2, x3, y3, x4, y4):
		self.x1 = x1
		self.x2 = x2
		self.x3 = x3
		self.x4 = x4
		self.y1 = y1
		self.y2 = y2
		self.y3 = y3
		self.y4 = y4

	def space(self):
		return Vector(self.x1, self.y1, self.x2, self.y2).count() * Vector(self.x2, self.y2, self.x3, self.y3).count()

class Triangle:

	def __init__(self, x1, y1, x2, y2, x3, y3):
		self.x1 = x1
		self.x2 = x2
		self.x3 = x3
		self.y1 = y1
		self.y2 = y2
		self.y3 = y3

	def space(self):
		v1 = Vector(self.x1, self.y1, self.x2, self.y2).count()
		v2 = Vector(self.x1, self.y1, self.x3, self.y3).count()
		v3 = Vector(self.x2, self.y2, self.x3, self.y3).count()
		p = (v1 + v2 + v3) / 2
		v1 = round(v1, 9)
		v2 = round(v2, 9)
		v3 = round(v3, 9)
		p = round(p, 9)
		return sqrt(p * (p - v1) * (p - v2) * (p - v3))
(n, d) = map(int, input().split())
amount = int(input())
req = []
for i in range(amount):
	(x, y) = map(int, input().split())
	req.append(Point(x, y))
sq = Square(0, d, n - d, n, n, n - d, d, 0)
S = sq.space()
EPS = 1e-05
for elem in req:
	space1 = Triangle(elem.x, elem.y, 0, d, n - d, n).space()
	space2 = Triangle(elem.x, elem.y, n - d, n, n, n - d).space()
	space3 = Triangle(elem.x, elem.y, n, n - d, d, 0).space()
	space4 = Triangle(elem.x, elem.y, d, 0, 0, d).space()
	if abs(space1 + space2 + space3 + space4 - S) <= EPS:
		print('YES')
	else:
		print('NO')


(n, d) = [int(x) for x in input().split()]
m = int(input())
for _ in range(m):
	(x, y) = [int(x) for x in input().split()]
	if x + y < d or x + y > 2 * n - d or x - y > d or (y - x > d):
		print('NO')
	else:
		print('YES')


def cornfield():
	temp = input().split(' ')
	n = int(temp[0])
	d = int(temp[1])
	num = int(input())
	for i in range(num):
		temp = input().split(' ')
		x = int(temp[0])
		y = int(temp[1])
		if y >= -x + d and y <= x + d and (y >= x - d) and (y <= -x + 2 * n - d):
			print('YES')
		else:
			print('NO')
cornfield()


(n, d) = map(int, input().split())
arr = [[0 for i in range(n + 1)] for j in range(n + 1)]
j = 0
if d > n / 2:
	d = n - d
	for i in range(d):
		for u in range(j + 1):
			arr[i][d + u] = 1
			arr[i][d - u] = 1
		j += 1
	u = 0
	j = j * 2 + 1
	for i in range(d, n - d + 1):
		for i2 in range(j):
			arr[i][u + i2] = 1
		u += 1
	j -= 2
	for i in range(n - d + 1, n + 1):
		for i2 in range(j):
			arr[i][u + i2] = 1
		u += 1
		j -= 2
	m = int(input())
	for i in range(m):
		(a, b) = map(int, input().split())
		if arr[a][n - b] == 1:
			print('YES')
		else:
			print('NO')
else:
	for i in range(d):
		for u in range(j + 1):
			arr[i][d + u] = 1
			arr[i][d - u] = 1
		j += 1
	u = 0
	j = j * 2 + 1
	for i in range(d, n - d + 1):
		for i2 in range(j):
			arr[i][u + i2] = 1
		u += 1
	j -= 2
	for i in range(n - d + 1, n + 1):
		for i2 in range(j):
			arr[i][u + i2] = 1
		u += 1
		j -= 2
	m = int(input())
	for i in range(m):
		(a, b) = map(int, input().split())
		if arr[a][b] == 1:
			print('YES')
		else:
			print('NO')


(n, d) = map(int, input().split())
m = int(input())
grasshoppers = [tuple(map(int, input().split())) for _ in range(m)]
(x1, y1) = (0, d)
(x2, y2) = (d, 0)
(x3, y3) = (n, n - d)
(x4, y4) = (n - d, n)

def sign(p1, p2, p3):
	return (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1])

def pointInTriangle(pt, v1, v2, v3):
	b1 = sign(pt, v1, v2) < 0.0
	b2 = sign(pt, v2, v3) < 0.0
	b3 = sign(pt, v3, v1) < 0.0
	return b1 == b2 and b2 == b3
for (x, y) in grasshoppers:
	if pointInTriangle((x, y), (x1, y1), (x2, y2), (x3, y3)):
		print('YES')
		continue
	elif pointInTriangle((x, y), (x1, y1), (x4, y4), (x3, y3)):
		print('YES')
		continue
	elif pointInTriangle((x, y), (x2, y2), (x3, y3), (x1, y1)):
		print('YES')
		continue
	elif pointInTriangle((x, y), (x3, y3), (x1, y1), (x2, y2)):
		print('YES')
		continue
	elif pointInTriangle((x, y), (x1, y1), (x3, y3), (x4, y4)):
		print('YES')
		continue
	elif pointInTriangle((x, y), (x4, y4), (x1, y1), (x2, y2)):
		print('YES')
		continue
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())

def area(p):
	r = 0
	p.append(p[0])
	for i in range(len(p) - 1):
		r += (p[i + 1][0] - p[i][0]) * (p[i + 1][1] + p[i][1])
	return abs(r)
ps = [(0, d), (d, 0), (n, n - d), (n - d, n)]
for i in range(m):
	c = tuple(map(int, input().split()))
	if area([ps[0], ps[1], c]) + area([ps[1], ps[2], c]) + area([ps[2], ps[3], c]) + area([ps[3], ps[0], c]) == area(ps):
		print('YES')
	else:
		print('NO')


def main():
	(n, d) = map(int, input().split())
	m = int(input())
	p = [tuple(map(int, input().split())) for i in range(m)]
	if 2 * d <= n:
		for (x, y) in p:
			if 0 <= x <= d and -x + d <= y <= x + d:
				print('YES')
			elif d <= x <= n - d and x - d <= y <= x + d:
				print('YES')
			elif n - d <= x <= n and x - d <= y <= -x + 2 * n - d:
				print('YES')
			else:
				print('NO')
	else:
		for (x, y) in p:
			if 0 <= x <= n - d and -x + d <= y <= x + d:
				print('YES')
			elif n - d <= x <= d and -x + d <= y <= -x + 2 * n - d:
				print('YES')
			elif d <= x <= n and x - d <= y <= -x + 2 * n - d:
				print('YES')
			else:
				print('NO')
main()


nd = input().split(' ')
n = int(nd[0])
d = int(nd[1])
m = int(input())
rez = ''
for foo in range(m):
	kuzcoords = list(map(int, input().split()))
	x = kuzcoords[0]
	y = kuzcoords[1]
	if y <= x + d and y <= -x + 2 * n - d and (y >= x - d) and (y >= -x + d):
		rez += 'YES\n'
	else:
		rez += 'NO\n'
print(rez)


nd = input().split(' ')
(n, d) = (int(nd[0]), int(nd[1]))
m = int(input())
grasshoppers = []
for i in range(0, m):
	pos = input().split(' ')
	grasshoppers.append((int(pos[0]), int(pos[1])))
for grasshopper in grasshoppers:
	x = grasshopper[0]
	y = grasshopper[1]
	print('YES' if 2 * n - d >= x + y >= d >= x - y >= -d else 'NO')


(n, d) = map(int, input().split())
k = int(input())
for i in range(k):
	(x, y) = map(int, input().split())
	if x * (n - d) - (y - d) * (n - d) == 0:
		print('YES')
	elif (x - d) * (n - d) - y * (n - d) == 0:
		print('YES')
	elif x * (0 - d) - (y - d) * d == 0:
		print('YES')
	elif (x - (n - d)) * (n - d - n) - (y - n) * (n - (n - d)) == 0:
		print('YES')
	elif x * (n - d) - (y - d) * (n - d) > 0 and (x - d) * (n - d) - y * (n - d) < 0:
		if x * (0 - d) - (y - d) * d < 0 and (x - (n - d)) * (n - d - n) - (y - n) * (n - (n - d)) > 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


(n, d) = map(int, input().split())
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	if d <= y + x and d >= x - y and (2 * n - d >= y + x) and (d >= y - x):
		print('yes')
	else:
		print('no')


def f(x, y):
	global d, n
	if y >= -x + d and y >= x - d and (y <= x + d) and (y <= -x + 2 * n - d):
		print('YES')
	else:
		print('NO')
(n, d) = map(int, input().split())
count = int(input())
for i in range(count):
	(x, y) = map(int, input().split())
	f(x, y)


def vect(x1, y1, x2, y2, x3, y3):
	return (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)
(n, d) = map(int, input().split())
m = int(input())
lst = [(d, 0), (0, d), (n - d, n), (n, n - d)]
for x in range(m):
	f1 = False
	f2 = False
	(i, j) = map(int, input().split())
	for y in range(4):
		if vect(lst[y][0], lst[y][1], lst[(y + 1) % 4][0], lst[(y + 1) % 4][1], i, j) > 0:
			f1 = True
		elif vect(lst[y][0], lst[y][1], lst[(y + 1) % 4][0], lst[(y + 1) % 4][1], i, j) < 0:
			f2 = True
	if f1 and (not f2):
		print('YES')
	elif f2 and (not f1):
		print('YES')
	else:
		print('NO')


a = input().split(' ')
n = int(a[0])
d = int(a[1])
b = int(input())

def inRange(x, y):
	if x <= n:
		if y >= x - d:
			if y <= d + x:
				if y <= 2 * n - d - x:
					if y >= d - x:
						return True
	return False
cuzn = []
for i in range(b):
	cuzn.append(input().split(' '))
for cuz in cuzn:
	if inRange(int(cuz[0]), int(cuz[1])):
		print('YES')
	else:
		print('NO')


inp1 = input().split(' ')
n = int(inp1[0])
d = int(inp1[1])
m = int(input())
coords = []
for i in range(m):
	inp2 = input().split(' ')
	coords.append((int(inp2[0]), int(inp2[1])))
A = (0, d)
B = (n - d, n)
C = (n, n - d)
D = (d, 0)

def under_line(A, B, C):
	k = (A[1] - B[1]) / (A[0] - B[0])
	b = (A[0] * B[1] - A[1] * B[0]) / (A[0] - B[0])
	if C[1] < k * C[0] + b:
		return 1
	elif C[1] == k * C[0] + b:
		return -1
	else:
		return 0
for X in coords:
	if under_line(A, B, X) == 1 and under_line(B, C, X) == 1 and (under_line(A, D, X) == 0) and (under_line(D, C, X) == 0):
		print('YES')
	elif under_line(A, B, X) == -1 or under_line(B, C, X) == -1 or under_line(A, D, X) == -1 or (under_line(D, C, X) == -1):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
k = int(input())
a = [[int(j) for j in input().split()] for i in range(k)]
for i in range(k):
	if a[i][0] >= 0 and a[i][0] <= n and (a[i][1] >= 0) and (a[i][1] <= n):
		if a[i][1] <= d + a[i][0] and a[i][1] >= a[i][0] - d and (a[i][1] >= d - a[i][0]) and (a[i][1] <= -a[i][0] + 2 * n - d):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


Listx = ['#']
Listy = ['#']
(n, d) = map(int, input().split())
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	Listx.append(x)
	Listy.append(y)
for i in range(1, a + 1):
	x1 = Listx[i]
	y1 = Listy[i]
	if y1 - d <= x1 and x1 - d <= y1 and (x1 + y1 >= d) and (x1 + y1 <= 2 * n - d):
		print('YES')
	else:
		print('NO')


(d, n) = [int(x) for x in input().split()]
counter = int(input())
for item in range(counter):
	(a, b) = [int(x) for x in input().split()]
	if a <= d:
		if abs(a - n) <= b <= d - abs(d - n - a):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math

def detection(x, y, great, mal, n, d):
	if y <= great(x, n, d) and y >= mal(x, d):
		return 'YES'
	else:
		return 'NO'

def mal(x, d):
	return math.fabs(x - d)

def great(x, n, d):
	return -math.fabs(x - n + d) + n
vvod1 = input()
vvod_nd = vvod1.split(' ')
n = int(vvod_nd[0])
d = int(vvod_nd[1])
m = int(input())
list_of_kuz = []
for i in range(m):
	a = input()
	aa = a.split(' ')
	aaa = [int(x) for x in aa]
	list_of_kuz.append(aaa)
list_answers = [detection(k[0], k[1], great, mal, n, d) for k in list_of_kuz]
for i in list_answers:
	print(i)


def check(n, d, x, y):
	if y >= -x + d and y <= 2 * n - d - x and (y <= d + x) and (y >= x - d):
		return True
	return False
(n, d) = list(map(int, input().split()))
m = int(input())
ans = []
for i in range(m):
	(x, y) = list(map(int, input().split()))
	if check(n, d, x, y):
		ans.append('YES')
	else:
		ans.append('NO')
for i in range(m):
	print(ans[i])


coor = input().split()
coor = [int(num) for num in coor]
GrassHopper = []
n = int(input())
Pos = []
for i in range(n):
	points = input().split()
	points = [int(num) for num in points]
	GrassHopper.append(points)
Line1 = coor[1]
Line2 = coor[1]
Line3 = coor[0] * 2 - coor[1]
Line4 = -coor[1]
i = 0
for point in GrassHopper:
	j = 0
	addi = point[0] + point[1]
	subs = point[0] - point[1]
	if addi >= Line2 and addi <= Line3:
		if subs >= Line4 and subs <= Line1:
			j = 1
			Pos.append('YES')
	if not j:
		Pos.append('NO')
for pos in Pos:
	print(pos)


(n, d) = map(int, input().split())
m = int(input())
for _ in range(m):
	(x, y) = map(int, input().split())
	first = y <= x + d
	second = y >= x - d
	third = y >= -x + d
	fourth = y <= -x + 2 * n - d
	if first and second and third and fourth:
		print('YES')
	else:
		print('NO')


def cornfield():
	t = input()
	n = int(t.split()[0])
	d = int(t.split()[1])
	g = int(input())
	result = []
	for i in range(g):
		c = input()
		x = int(c.split()[0])
		y = int(c.split()[1])
		if y <= -x + 2 * n - d and y <= x + d and (y >= d - x) and (y >= x - d):
			result.append('YES')
		else:
			result.append('NO')
	for i in result:
		print(i)
cornfield()


c = input().split(' ')
n = int(c[0])
d = int(c[1])
kuz_n = int(input())
ans = []
for i in range(kuz_n):
	kuz = input().split(' ')
	kuz[0] = int(kuz[0])
	kuz[1] = int(kuz[1])
	if kuz[0] + d >= kuz[1] and kuz[0] - d <= kuz[1]:
		if d - kuz[0] <= kuz[1] and 2 * n - d - kuz[0] >= kuz[1]:
			ans.append('YES')
		else:
			ans.append('NO')
	else:
		ans.append('NO')
for i in ans:
	print(i)


(n, d) = map(int, input().split())
for testis in range(int(input())):
	(x, y) = map(int, input().split())
	f = 0
	if x + y - d >= 0 and x - y - d <= 0 and (x + y - 2 * n + d <= 0) and (x - y + d >= 0):
		f = 1
	if f == 0:
		print('NO')
	else:
		print('YES')


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
(n, d) = mi()
m = ii()
for i in range(m):
	(x, y) = mi()
	if y >= d - x and y >= x - d and (y <= 2 * n - d - x) and (y <= x + d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
list = ''
a1 = d
b1 = d
c1 = 0 * 0 - d * d
a2 = 0 - (n - d)
b2 = n - d
c2 = d * (n - d) - n * 0
a3 = n - d - n
b3 = n - d - n
c3 = n * n - (n - d) * (n - d)
a4 = n - d
b4 = 0 - (n - d)
c4 = (n - d) * d - 0
for i in range(0, m):
	(x, y) = map(int, input().split())
	if x >= (-b1 * y - c1) / a1 and x <= (-b2 * y - c2) / a2 and (x <= (-b3 * y - c3) / a3) and (x >= (-b4 * y - c4) / a4):
		print('YES')
	else:
		print('NO')


def solve1(x, y, d, n):
	if x <= d:
		y1 = -x + d
		y2 = x + d
		if y >= y1 and y <= y2:
			return True
		return False
	elif x <= n - d:
		y1 = x - d
		y2 = x + d
		if y >= y1 and y <= y2:
			return True
		return False
	else:
		y1 = x - d
		y2 = -x + 2 * n - d
		if y >= y1 and y <= y2:
			return True
		return False

def solve2(x, y, d, n):
	if x <= n - d:
		y1 = -x + d
		y2 = x + d
		if y >= y1 and y <= y2:
			return True
		return False
	elif x <= d:
		y1 = d - x
		y2 = -x + 2 * n - d
		if y >= y1 and y <= y2:
			return True
		return False
	else:
		y1 = x - d
		y2 = -x + 2 * n - d
		if y >= y1 and y <= y2:
			return True
		return False

def main():
	(n, d) = [int(elem) for elem in input().split()]
	m = int(input())
	ans = []
	k1 = 1
	b1 = -d
	k2 = -1
	b2 = 2 * d
	for i in range(m):
		(x, y) = [int(elem) for elem in input().split()]
		if n - d >= d:
			if solve1(x, y, d, n):
				ans.append('YES')
			else:
				ans.append('NO')
		elif solve2(x, y, d, n):
			ans.append('YES')
		else:
			ans.append('NO')
	for st in ans:
		print(st)
main()


(n, d) = map(int, input().split())
t = int(input())
p = 0

def checkin(x, y):
	c = 0
	if y - d >= -1 * x:
		c += 1
	if y - 0 >= x - d:
		c = c + 1
	if y - (n - d) <= -1 * (x - n):
		c = c + 1
	if y - n <= x - (n - d):
		c = c + 1
	return c
for i in range(t):
	(x, y) = map(int, input().split())
	p = checkin(x, y)
	if p == 4:
		print('YES')
	else:
		print('NO')


k = list(map(int, input().split()))
n = int(input())
res = []
pole = []
if k[1] <= k[0] - k[1]:
	for i in range(k[1] + 1):
		pole.append([k[1] - i, k[1] + i])
	for i in range(k[1] + 1, k[0] - k[1] + 1):
		pole.append([pole[i - 1][0] + 1, pole[i - 1][1] + 1])
	for i in range(k[0] - k[1] + 1, k[0] + 1):
		pole.append([pole[i - 1][0] + 1, pole[i - 1][1] - 1])
else:
	for i in range(k[0] - k[1] + 1):
		pole.append([k[1] - i, k[1] + i])
	for i in range(k[0] - k[1] + 1, k[1] + 1):
		pole.append([pole[i - 1][0] - 1, pole[i - 1][1] - 1])
	for i in range(k[1] + 1, k[0] + 1):
		pole.append([pole[i - 1][0] + 1, pole[i - 1][1] - 1])
for i in range(n):
	kuz = input().split()
	if pole[int(kuz[0])][0] <= int(kuz[1]) and pole[int(kuz[0])][1] >= int(kuz[1]):
		res.append('YES')
	else:
		res.append('NO')
for i in range(n):
	print(res[i])


(n, d) = map(int, input().split())
elems = 0
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	q1 = x + d
	q2 = x - d
	q3 = -x + d
	q4 = -x + n + n - d
	if y <= q1 and y >= q2 and (y >= q3) and (y <= q4):
		print('YES')
	else:
		print('NO')


alph = 'abcdefghijklmnopqrstuvwxyz'
(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	f = y - x <= d and y - x >= -d and (y + x >= d) and (x + y <= 2 * n - d)
	if f:
		print('YES')
	else:
		print('NO')


v = input()
n = int(v.split(' ')[0])
d = int(v.split(' ')[1])
m = int(input())
ans = ''
for i in range(m):
	v = input()
	x = int(v.split(' ')[0])
	y = int(v.split(' ')[1])
	s = n * 2 - d
	if y >= -x + d and y <= -x + s and (y >= x - d) and (y <= x + d):
		ans += 'YES\n'
	else:
		ans += 'NO\n'
print(ans)


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	f1 = x + d
	f2 = -x + n + (n - d)
	f3 = x - d
	f4 = -x + d
	if y <= min(f1, f2) and y >= max(f3, f4):
		print('YES')
	else:
		print('NO')


(n, d) = [int(i) for i in input().split()]
m = int(input())
for i in range(m):
	(x, y) = [int(i) for i in input().split()]
	c1 = d <= x + y <= 2 * n - d
	c2 = abs(x - y) <= d
	if c1 and c2:
		print('YES')
	else:
		print('NO')


class Line:

	def __init__(self, px0, py0, px1, py1):
		(self.px0, self.py0, self.px1, self.py1) = (px0, py0, px1, py1)

	def is_on_line(self, x, y):
		(x0, y0) = (self.px0 - x, self.py0 - y)
		(x1, y1) = (self.px1 - x, self.py1 - y)
		return x0 * y1 == x1 * y0 and x0 * x1 <= 0

	def is_on_top(self, x, y):
		return y > self.py0 + (x - self.px0) * (self.py1 - self.py0) / (self.px1 - self.px0)

	def is_on_right(self, x, y):
		return x > self.px0 + (y - self.py0) * (self.px1 - self.px0) / (self.py1 - self.py0)
(n, d) = tuple(map(int, input().split()))
m = int(input())
lines = (Line(0, d, d, 0), Line(d, 0, n, n - d), Line(n, n - d, n - d, n), Line(n - d, n, 0, d))
while m:
	m -= 1
	(x, y) = tuple(map(int, input().split()))
	for ln in lines:
		if ln.is_on_line(x, y):
			print('YES')
			break
	else:
		if lines[0].is_on_right(x, y) and lines[0].is_on_top(x, y) and (not lines[1].is_on_right(x, y)) and lines[1].is_on_top(x, y) and (not lines[2].is_on_right(x, y)) and (not lines[2].is_on_top(x, y)) and lines[3].is_on_right(x, y) and (not lines[3].is_on_top(x, y)):
			print('YES')
		else:
			print('NO')


(n, d) = map(int, input().split())
m = int(input())
data = []
for i in range(0, m, 1):
	(x, y) = map(int, input().split())
	l1 = y <= x + d
	l2 = y >= d - x
	l3 = y >= x - d
	l4 = y <= 2 * n - x - d
	if l1 and l2 and l3 and l4:
		data.append('YES')
	else:
		data.append('NO')
for a in data:
	print(a)


a = [int(x) for x in input().split()]
n = a[0]
d = a[1]
l = 2 * n
m = int(input())
for i in range(m):
	e = [int(x) for x in input().split()]
	x = e[0]
	y = e[1]
	if y >= x - d and y <= x + d and (y >= d - x) and (y <= 2 * n - d - x):
		print('YES')
	else:
		print('NO')


X = list(map(int, input().split(' ')))
for i in range(int(input())):
	Temp = list(map(int, input().split(' ')))
	print('YES' if abs(Temp[0] - Temp[1]) <= X[1] and X[1] <= sum(Temp) <= 2 * X[0] - X[1] else 'NO')


def make_line(x1, y1, x2, y2):
	line = []
	line.append(y1 - y2)
	line.append(x2 - x1)
	line.append(x1 * y2 - x2 * y1)
	return line

def make_lines(n, d):
	lines.append(make_line(0, d, d, 0))
	lines.append(make_line(0, d, n - d, n))
	lines.append(make_line(d, 0, n, n - d))
	lines.append(make_line(n, n - d, n - d, n))
	return lines

def check(x, y):
	pointer = []
	for l in lines:
		if l[1] == 0:
			pointer.append(0)
		else:
			pointer.append((x * l[0] + l[2]) / -l[1])
	if y >= pointer[0] and pointer[2] <= y <= pointer[1] and (y <= pointer[3]):
		print('YES')
	else:
		print('NO')
s = input().split(' ')
lines = []
m = int(s[0])
k = int(s[1])
make_lines(m, k)
z = int(input())
for i in range(z):
	s = input().split(' ')
	m = int(s[0])
	k = int(s[1])
	check(m, k)


(n, d) = [int(i) for i in input().split()]
k = int(input())
z = []
for i in range(k):
	(x, y) = [int(i) for i in input().split()]
	z.append((x, y))
for (x, y) in z:
	b1 = y >= -x + d
	b2 = y >= x - d
	b3 = y <= x + d
	b4 = y <= -x + 2 * n - d
	if b1 and b2 and b3 and b4:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().strip().split())
m = int(input().strip())
lb = n + n - d
for _ in range(m):
	(x, y) = map(int, input().strip().split())
	if not (x - y <= d and x - y >= -d) or not (x + y <= lb and x + y >= d):
		print('NO')
	else:
		print('YES')


(n, d) = map(int, input().split())
m = int(input())

def f(x):
	return -abs(x - (n - d)) + n

def g(x):
	return abs(x - d)
ok = True
for _ in range(m):
	(x, y) = map(int, input().split())
	if y <= f(x) and y >= g(x):
		print('YES')
	else:
		print('NO')


import sys
n_and_d = input()
n_and_d = n_and_d.split()
(n, d) = (int(n_and_d[0]), int(n_and_d[1]))
rt_1 = (0, d)
rt_3 = (n, n - d)
rt_4 = (n - d, n)
rt_2 = (d, 0)
grassHoppers = int(input())
while grassHoppers > 0:
	gH_cord = input()
	gH_cord = gH_cord.split()
	(x, y) = (int(gH_cord[0]), int(gH_cord[1]))
	if x + y - d >= 0 and x + y - 2 * n + d <= 0 and (x - y - d <= 0) and (x - y + d >= 0):
		print('YES')
	else:
		print('NO')
	grassHoppers -= 1


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	ans = True
	if not (x - y >= -d and x - y <= d):
		ans = False
	if not (x + y >= d and x + y <= 2 * n - d):
		ans = False
	if ans:
		print('YES')
	else:
		print('NO')


from math import sqrt
(n, d) = list(map(int, input().split(' ')))
points = []
for i in range(int(input())):
	point = list(map(int, input().split(' ')))
	points.append(point)

def inRec(x, y):
	c = 0
	if (y <= x + d) & (y >= x - d) & (y <= -x + 2 * n - d) & (y >= -x + d):
		c = 1
	return 'YES' if c else 'NO'
for i in points:
	print(inRec(i[0], i[1]))


(n, d) = map(int, input().split())
grass = int(input())
res = []
for i in range(grass):
	(x, y) = map(int, input().split())
	if abs(x - y) <= d and x + y >= d and (x + y <= 2 * n - d):
		print('YES')
	else:
		print('NO')


(n, d) = list(map(int, input().split(' ')))
for i in range(int(input())):
	(x, y) = list(map(int, input().split(' ')))
	flag = True
	if abs(x - y) <= d and x + y >= d and (x + y <= 2 * n - d):
		flag = False
	print('YES' if flag == False else 'NO')


from math import *

class TPoint:

	def __init__(self, x, y):
		self.x = x
		self.y = y

class TLine:

	def __init__(self, A, B, C):
		self.A = A
		self.B = B
		self.C = C

def readpoint():
	x = float(input())
	y = float(input())
	A = TPoint(x, y)
	return A

def points_toline(P, Q):
	A = P.y - Q.y
	B = Q.x - P.x
	C = -A * P.x - B * P.y
	return TLine(A, B, C)

def eq(a, b):
	eps = 1e-05
	return abs(a - b) < eps
eps = 0.0001

def linespoint(a, b):
	if eq(a.B * b.A, a.A * b.B):
		if eq(a.A * b.C, b.A * a.C) and eq(a.B * b.C, b.B * a.C):
			return (2, (0, 0))
		else:
			return (0, (0, 0))
	elif abs(a.B) >= eps and abs(b.B) >= eps:
		x = (a.C / a.B - b.C / b.B) / (b.A / b.B - a.A / a.B)
		y = -a.A / a.B * x - a.C / a.B
		return TPoint(x, y)
	elif abs(a.B) <= eps and abs(b.B) >= eps:
		x = -a.C / a.A
		y = -b.A / b.B * x - b.C / b.B
		return TPoint(x, y)
	elif abs(a.B) >= eps and abs(b.B) <= eps:
		x = -b.C / b.A
		y = -a.A / a.B * x - a.C / a.B
		return TPoint(x, y)

def rasst(P, Q):
	return ((P.x - Q.x) ** 2 + (P.y - Q.y) ** 2) ** 0.5

def distance_point_to_line(P, A, B, C):
	l = TLine(A, B, C)
	n = perpen(l, P)
	Q = linespoint(l, n)
	return rasst(P, Q)

def bisectorspoint(P, Q, R):
	p = rasst(Q, R)
	q = rasst(P, R)
	r = rasst(P, Q)
	Mr = TPoint((q * Q.x + p * P.x) / (p + q), (q * Q.y + p * P.y) / (p + q))
	Mp = TPoint((q * Q.x + r * R.x) / (r + q), (q * Q.y + r * R.y) / (r + q))
	lr = points_toline(R, Mr)
	lp = points_toline(P, Mp)
	I = linespoint(lr, lp)
	return I

def perpen(l, P):
	return TLine(l.B, -l.A, -l.B * P.x + l.A * P.y)

def inotr(P, M, N):
	l = points_toline(M, N)
	if eq(l.B * P.y, -l.C - l.A * P.x) and (P.x <= M.x and P.x >= N.x or (P.x >= M.x and P.x <= N.x)) and (P.y <= M.y and P.y >= N.y or (P.y >= M.y and P.y <= N.y)):
		return 'YES'
	else:
		return 'NO'

def inmnog():
	res = []
	r = input().split()
	n = int(r[0])
	d = int(r[1])
	A = TPoint(0, d)
	B = TPoint(d, 0)
	C = TPoint(n, n - d)
	D = TPoint(n - d, n)
	w = 1
	points = [A, B, C, D]
	k = int(input())
	for i in range(k):
		w = 1
		r = input().split()
		T = TPoint(int(r[0]), int(r[1]))
		if inotr(T, A, B) == 'YES':
			res.append('YES')
		elif inotr(T, B, C) == 'YES':
			res.append('YES')
		elif inotr(T, C, D) == 'YES':
			res.append('YES')
		elif inotr(T, D, A) == 'YES':
			res.append('YES')
		else:
			P = points[0]
			Q = points[1]
			l = TPoint(Q.x - P.x, Q.y - P.y)
			m = TPoint(T.x - P.x, T.y - P.y)
			if l.x * m.y - l.y * m.x >= 0:
				for j in range(4):
					P = points[j]
					Q = points[(j + 1) % 4]
					l = TPoint(Q.x - P.x, Q.y - P.y)
					m = TPoint(T.x - P.x, T.y - P.y)
					if l.x * m.y - l.y * m.x < 0:
						w = -1
						break
			elif l.x * m.y - l.y * m.x <= 0:
				for j in range(4):
					P = points[j]
					Q = points[(j + 1) % 4]
					l = TPoint(Q.x - P.x, Q.y - P.y)
					m = TPoint(T.x - P.x, T.y - P.y)
					if l.x * m.y - l.y * m.x > 0:
						w = -1
						break
			if w == 1:
				res.append('YES')
			else:
				res.append('NO')
	for i in res:
		print(i)
inmnog()


w = input()
w = w.split()
n = int(w[0])
d = int(w[1])
m = int(input())
i = 1
c = []
while i <= m:
	k = input()
	k = k.split()
	c.append(k)
	i += 1
i = 0
while i <= m - 1:
	r = c[i][1]
	e = c[i][0]
	r = int(r)
	e = int(e)
	if r == d - e or r == d + e or r == 2 * n - d - e or (r == e - d):
		print('YES')
	elif r + e > d and r - e < d and (r + e < 2 * n - d) and (e - r < d):
		print('Yes')
	else:
		print('No')
	i += 1


from math import hypot, atan2, sin, cos, radians
EPSILON = 1e-06
(n, d) = map(int, input().split())

def rotate(x, y):
	di = hypot(x, y)
	r = atan2(x, y) + radians(45)
	return (sin(r) * di, cos(r) * di)
(xrs, yrs) = rotate(d, 0)
(xre, yre) = rotate(n - d, n)
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	(x, y) = rotate(x, y)
	if xrs - EPSILON <= x <= xre + EPSILON and yrs - EPSILON <= y <= yre + EPSILON:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
l = []

def func(l):
	a = (l[0] - l[2]) * (l[5] - l[3]) - (l[1] - l[3]) * (l[4] - l[2])
	b = (l[0] - l[8]) * (l[7] - l[9]) - (l[1] - l[9]) * (l[6] - l[8])
	c = (l[0] - l[4]) * (l[7] - l[5]) - (l[1] - l[5]) * (l[6] - l[4])
	d = (l[0] - l[2]) * (l[9] - l[3]) - (l[1] - l[3]) * (l[8] - l[2])
	if (a <= 0 and b >= 0 or (a >= 0 and b <= 0)) and (c <= 0 and d >= 0 or (c >= 0 and d <= 0)):
		return True
	return False
for i in range(m):
	(x, y) = map(int, input().split())
	l.append(list())
	l[-1] = [x, y, 0, d, d, 0, n, n - d, n - d, n, 0, d]
for i in range(m):
	if func(l[i]):
		print('YES')
	else:
		print('NO')


c = input().split(' ')
n = int(c[0])
d = int(c[1])
x1 = d
y1 = 0
x2 = 0
y2 = d
x3 = n
y3 = n - d
x4 = n - d
y4 = n
sver_n = int(input())
sver_x = []
sver_y = []
for i in range(0, sver_n):
	sver = input().split(' ')
	sver_x.append(int(sver[0]))
	sver_y.append(int(sver[1]))
b1 = x2 - x1
b2 = y2 - y1
d1 = x3 - x1
d2 = y3 - y1
for i in range(0, sver_n):
	x = sver_x[i]
	y = sver_y[i]
	if (x - x1) * b1 + (y - y1) * b2 < 0.0:
		print('NO')
		continue
	if (x - x2) * b1 + (y - y2) * b2 > 0.0:
		print('NO')
		continue
	if (x - x1) * d1 + (y - y1) * d2 < 0.0:
		print('NO')
		continue
	if (x - x3) * d1 + (y - y3) * d2 > 0.0:
		print('NO')
		continue
	print('YES')


def get():
	q = list(map(int, input().split()))
	if len(q) == 1:
		[q] = q
	return q
(n, d) = get()
e = get()
for r in range(e):
	(a, s) = get()
	if 2 * n - d >= a + s >= d and -d <= a - s <= d:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())

def z(a, b, c, d, g, h):
	q = (c - a) * (h - b) - (d - b) * (g - a)
	return 0 if q < 0 else 1
for i in range(m):
	(x, y) = map(int, input().split())
	print('YES' if 3 < z(d, 0, n, n - d, x, y) + z(0, d, d, 0, x, y) + z(n - d, n, 0, d, x, y) + z(n, n - d, n - d, n, x, y) or (x, y) == (n, n - d) or (x, y) == (n - d, n) or ((x, y) == (0, d)) or ((x, y) == (d, 0)) else 'NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(a, b) = map(int, input().split())
	eqn1 = a + b - d
	eqn2 = -a + b - d
	eqn3 = a + b - 2 * n + d
	eqn4 = -a + b + d
	if eqn1 >= 0 and eqn2 <= 0 and (eqn3 <= 0) and (eqn4 >= 0):
		print('YES')
	else:
		print('NO')


(d, x) = map(int, input().split())
(d, x) = (x, d)
n = int(input())
x1 = d
y1 = 0
x2 = x
y2 = x - d
x3 = 0
y3 = d
x4 = x - d
y4 = x
x22 = x2 - x1
y22 = y2 - y1
x11 = x3 - x1
y11 = y3 - y1
x33 = x4 - x2
y33 = y4 - y2
x44 = x4 - x3
y44 = y4 - y3
for i in range(n):
	(u, i) = map(int, input().split())
	c = 1
	if x11 * (i - y1) - y11 * (u - x1) > 0:
		c = 0
	if x22 * (i - y1) - y22 * (u - x1) < 0:
		c = 0
	if x33 * (i - y2) - y33 * (u - x2) < 0:
		c = 0
	if x44 * (i - y3) - y44 * (u - x3) > 0:
		c = 0
	if c == 1:
		print('YES')
	else:
		print('NO')


def verifyBorders(d, n, x, y):
	if y + d >= x and x + d >= y and (x + y + d <= 2 * n) and (x + y >= d):
		print('YES')
	else:
		print('NO')
(n, d) = [int(i) for i in input().split()]
m = int(input())
for i in range(m):
	(x, y) = [int(j) for j in input().split()]
	verifyBorders(d, n, x, y)


def new_c(x, y):
	return (x + y, x - y)
(n, d) = map(int, input().split())
(x_1, y_1) = new_c(0, d)
(x_2, y_2) = new_c(d, 0)
(x_3, y_3) = new_c(n, n - d)
(x_4, y_4) = new_c(n - d, n)
x1 = min(x_1, x_2, x_3, x_4)
y1 = min(y_1, y_2, y_3, y_4)
x2 = max(x_1, x_2, x_3, x_4)
y2 = max(y_1, y_2, y_3, y_4)
for i in range(int(input())):
	(x, y) = new_c(*map(int, input().split()))
	if x1 <= x <= x2 and y1 <= y <= y2:
		print('YES')
	else:
		print('NO')


(n, d) = input().split()
c = 0
a = []
n = float(n)
d = int(d)
m = int(input())
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if d <= n / 2:
		if x <= d:
			if d - x <= y <= d + x:
				c += 1
		if d < x <= n - d:
			if x - d <= y <= x + d:
				c += 1
		if n - d < x <= n:
			if x - d <= y <= 2 * n - d - x:
				c += 1
	if d > n / 2:
		if x <= n - d:
			if d - x <= y <= d + x:
				c += 1
		if n - d <= x <= d:
			if d - x <= y <= 2 * n - x - d:
				c += 1
		if d <= x <= n:
			if x - d <= y <= 2 * n - d - x:
				c += 1
	if c == 0:
		a.append('NO')
	else:
		a.append('YES')
		c = 0
for j in range(len(a)):
	print(a[j])


a = list(map(int, input().split()))
n = a[0]
d = a[1]
m = int(input())
XY = []
for i in range(m):
	par = list(input().split())
	XY.append(par)
for (r1, r2) in XY:
	x = int(r1)
	y = int(r2)
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + n * 2 - d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
points = list()
answers = list()
for i in range(m):
	points.append(tuple(map(int, input().split())))
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
for point in points:
	dx = x2 - x1
	dy = y2 - y1
	d1 = ((y1 - point[1]) * dx + (point[0] - x1) * dy) / (dy * dy + dx * dx)
	dx = x3 - x2
	dy = y3 - y2
	d2 = ((y2 - point[1]) * dx + (point[0] - x2) * dy) / (dy * dy + dx * dx)
	dx = x4 - x3
	dy = y4 - y3
	d3 = ((y3 - point[1]) * dx + (point[0] - x3) * dy) / (dy * dy + dx * dx)
	dx = x1 - x4
	dy = y1 - y4
	d4 = ((y4 - point[1]) * dx + (point[0] - x4) * dy) / (dy * dy + dx * dx)
	if d1 <= 0 and d2 <= 0 and (d3 <= 0) and (d4 <= 0):
		answers.append('YES')
	else:
		answers.append('NO')
for answer in answers:
	print(answer)


(n, d) = list(map(int, input().split()))
m = int(input())

def lfunc(x1, y1, x2, y2, x):
	if x2 != x1:
		k = (y2 - y1) / (x2 - x1)
	else:
		k = 0
	b = y1 - k * x1
	return k * x + b
k = 0
for i in range(m):
	(x, y) = list(map(int, input().split()))
	if y <= lfunc(0, d, n - d, n, x) and y >= lfunc(d, 0, n, n - d, x) and (y <= lfunc(n, n - d, n - d, n, x)) and (y >= lfunc(d, 0, 0, d, x)):
		print('YES')
	else:
		print('NO')


(n, d) = [int(i) for i in input().split()]
m = int(input())
for j in range(m):
	o = False
	(x, y) = [int(i) for i in input().split()]
	if y <= x + d and y >= x - d:
		if -x + 2 * n - d > -x + d:
			if y <= -x + 2 * n - d and y >= -x + d:
				print('yes')
				o = True
	if not o:
		print('no')


(n, d) = map(int, input().split())
m = int(input())
q = n + n - d
for i in range(m):
	(x, y) = map(int, input().split())
	if y > x + d:
		print('NO')
	elif y < x - d:
		print('NO')
	elif x < d - y:
		print('NO')
	elif y + x > q:
		print('NO')
	else:
		print('YES')


(n, d) = map(int, input().split())
struct = {}
for i in range(n + 1):
	struct[i] = (i + d if i + d < n else n - (i + d) % n, abs(i - d))
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if struct[x][1] <= y <= struct[x][0]:
		print('YES')
	else:
		print('NO')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def dist(x, y, c, d):
	return mt.sqrt((x - c) ** 2 + (y - d) ** 2)
(n, d) = M()
m = I()
for i in range(m):
	(a, b) = M()
	if a - b - d <= 0 and a - b + d >= 0:
		if a + b - d >= 0 and a + b + d - 2 * n <= 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(0, m):
	(a, b) = map(int, input().split())
	if (a <= n) & (b <= n) & (b >= d - a) & (b <= d + a) & (b >= a - d) & (b <= 2 * n - a - d):
		print('YES')
	else:
		print('NO')


l = list(map(int, input().split()))
n = l[0]
d = l[1]
m = int(input())
coords = []
for i in range(m):
	coord = list(map(int, input().split()))
	coords.append(coord)
for coord in coords:
	x = coord[0]
	y = coord[1]
	if -x + y - d <= 0 and x + y - d >= 0 and (x - y - d <= 0) and (x + y + d - 2 * n <= 0):
		print('YES')
	else:
		print('NO')


import sys

def area(p1, p2, p3):
	p = [p1, p2, p3]
	s = 0
	for i in range(3):
		s += p[i][1] * (p[(i + 1) % 3][0] - p[(i + 2) % 3][0])
	return abs(s)

def check(p1, p2, p3, p4, p):
	A0 = area(p1, p2, p3) + area(p1, p4, p3)
	A1 = area(p, p1, p2)
	A2 = area(p, p2, p3)
	A3 = area(p, p3, p4)
	A4 = area(p, p4, p1)
	return A0 == A1 + A2 + A3 + A4
(n, d) = map(int, input().split())
p1 = (d, 0)
p2 = (n, n - d)
p3 = (n - d, n)
p4 = (0, d)
m = int(input())
for _ in range(m):
	(x, y) = map(int, input().split())
	if check(p1, p2, p3, p4, (x, y)):
		print('YES')
	else:
		print('NO')


(n, d) = tuple(map(int, input().split()))
m = int(input())

def func1(x):
	return x + d

def func2(x):
	return x - d

def func3(x):
	return -x + d

def func4(x):
	return (n - d) * 2 - x + d
for i in range(m):
	(x, y) = tuple(map(int, input().split()))
	if func2(x) <= y <= func1(x) and func3(x) <= y <= func4(x):
		print('YES')
	else:
		print('NO')


nd = list(map(int, input().split()))
m = int(input())
f1 = lambda x: x - nd[1]
f2 = lambda x: x + nd[1]
f3 = lambda x: -x + nd[1]
f4 = lambda x: -x + 2 * nd[0] - nd[1]
r = []
for i in range(m):
	xiyi = list(map(int, input().split()))
	if xiyi[1] >= f1(xiyi[0]) and xiyi[1] <= f2(xiyi[0]) and (xiyi[1] >= f3(xiyi[0])) and (xiyi[1] <= f4(xiyi[0])):
		r.append('YES')
	else:
		r.append('NO')
for el in r:
	print(el)


(n, d) = map(int, input().split())
m = int(input())
while m:
	m -= 1
	(x, y) = map(int, input().split())
	diag1 = x + y
	diag2 = x - y
	if d <= diag1 <= 2 * n - d and -d <= diag2 <= d:
		print('YES')
	else:
		print('NO')


[n, d] = map(int, input().split())
m = int(input())
gh = []
cohor = [1, 2]
for i in range(m):
	cohor = list(map(int, input().split()))
	gh.append(cohor)
for i in gh:
	if (i[0] + i[1] >= d) & (i[0] + i[1] <= 2 * n - d) & (abs(i[0] - i[1]) <= d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
if n >= 2 * d:
	for i in range(m):
		found = False
		(x, y) = map(int, input().split())
		if 0 <= x and x <= d and (d - x <= y) and (x + d >= y):
			found = True
		if d <= x and x <= n - d and (x - d <= y) and (x + d >= y):
			found = True
		if n - d <= x and x <= n and (x - d <= y) and (-x + 2 * n - d >= y):
			found = True
		if found:
			print('YES')
		else:
			print('NO')
else:
	for i in range(m):
		found = False
		(x, y) = map(int, input().split())
		if 0 <= x and x <= n - d and (d - x <= y) and (x + d >= y):
			found = True
		if n - d < x and x <= d and (d - x <= y) and (-x + 2 * n - d >= y):
			found = True
		if d < x and x <= n and (x - d <= y) and (-x + 2 * n - d >= y):
			found = True
		if found:
			print('YES')
		else:
			print('NO')


def check(n, d, x, y):
	return x - d <= y <= x + d and d <= x + y <= n + n - d

def field(n, d, lst):
	a = list()
	for elem in lst:
		if check(n, d, elem[0], elem[1]):
			a.append('YES')
		else:
			a.append('NO')
	return a
(N, D) = [int(i) for i in input().split()]
q = int(input())
b = list()
for j in range(q):
	(X, Y) = [int(z) for z in input().split()]
	b.append([X, Y])
print(*field(N, D, b), sep='\n')


def f():
	(n, d) = [int(x) for x in input().split()]
	m = int(input())
	points = []
	for i in range(m):
		(x, y) = [int(x) for x in input().split()]
		points.append((x, y))
	t1 = (n - d, n - d)
	t2 = (n - d, n - d)
	ta = (-d, d)
	tb = (-d, d)
	for p in points:
		(x, y) = p
		ok1 = t1[0] * (y - d) - t1[1] * x <= 0 and t2[0] * y - t2[1] * (x - d) >= 0
		ok2 = ta[0] * y - ta[1] * (x - d) <= 0 and tb[0] * (y + d - n) - tb[1] * (x - n) >= 0
		if ok1 and ok2:
			print('YES')
		else:
			print('NO')
f()


(m, n) = map(int, input().split())
nn = int(input())
a = []

def y0(x):
	global m, n
	return x + n

def y1(x):
	global m, n
	return 2 * m - n - x

def y2(x):
	global m, n
	return x - n

def y3(x):
	global m, n
	return n - x
for i in range(nn):
	xx = input().split()
	xx[0] = int(xx[0])
	xx[1] = int(xx[1])
	a.append(xx)
for i in range(nn):
	if y0(a[i][0]) >= a[i][1] and y1(a[i][0]) >= a[i][1] and (y2(a[i][0]) <= a[i][1]) and (y3(a[i][0]) <= a[i][1]):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	rx = n - x
	ry = n - y
	rt = n - d
	if (x + y < d) | (x + y > 2 * n - d) | (x + ry < rt) | (rx + y < rt):
		print('NO')
	else:
		print('YES')


import math
(n, d) = [int(x) for x in input().split()]
for i in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	if x + y >= d and x + y <= 2 * n - d and (abs(x - y) <= d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())

def is_here(x, y):
	if y >= -x + d and y <= -x + d + 2 * (n - d) and (y >= x - d) and (y <= x + d):
		print('YES')
	else:
		print('NO')
	return
for _ in range(m):
	(x, y) = map(int, input().split())
	is_here(x, y)


(n, d) = map(int, input().split())
m = int(input())
sol = []
for _ in range(m):
	(x, y) = map(int, input().split())
	if (y - x - d) * (y - d + x) <= 0:
		if (y - 2 * n + d + x) * (y - x + d) <= 0:
			sol.append('YES')
		else:
			sol.append('NO')
	else:
		sol.append('NO')
print(*sol, sep='\n')


(n, d) = map(int, input().split())
k = int(input())
for i in range(k):
	(a, b) = map(int, input().split())
	if abs(a - d) <= b and abs(a + d - n) <= n - b:
		print('YES')
	else:
		print('NO')


(n, d) = input().split(' ')
n = int(n)
d = int(d)
m = int(input())
arr = []
for i in range(m):
	a = input().split(' ')
	a1 = max(int(a[0]), int(a[1]))
	a2 = min(int(a[0]), int(a[1]))
	arr.append([a1, a2])
for i in range(m):
	a1 = arr[i][0]
	a2 = arr[i][1]
	x1 = a2 <= a1 + d
	x2 = a2 >= a1 - d
	x3 = a2 >= d - a1
	x4 = a2 <= 2 * n - d - a1
	if x1 and x2 and x3 and x4:
		print('YES')
	else:
		print('NO')


A = []
Res = []
A = input().split()
for i in range(2):
	A[i] = int(A[i])
n = A[0]
d = A[1]
m = int(input())
for i1 in range(m):
	b = []
	b = input().split()
	for i2 in range(2):
		b[i2] = int(b[i2])
	x = b[0]
	y = b[1]
	if y <= x + d and y <= 2 * n - x - d and (y >= d - x) and (y >= x - d):
		Res.append('YES')
	else:
		Res.append('NO')
for i3 in range(m):
	print(Res[i3])


h = input().split(' ')
l = list(h)
k = False
n = int(l[0])
d = int(l[1])
m = int(input())
for i in range(m):
	t = input().split(' ')
	l = list(t)
	x = int(l[0])
	y = int(l[1])
	if (d <= x + y) & (x + y <= 2 * n - d) & (d * -1 <= x - y) & (x - y <= d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
kol = int(input())
a = []
for i in range(kol):
	(x, y) = map(int, input().split())
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + 2 * n - d):
		a.append('YES')
	else:
		a.append('NO')
for i in a:
	print(i)


(n, d) = list(map(int, input().split()))
num = int(input())
ans = []
for i in range(num):
	(x, y) = list(map(int, input().split()))
	if (x <= y + d and x >= y - d) and (x >= -y + d and x <= -y + 2 * n - d):
		ans.append('YES')
	else:
		ans.append('NO')
for a in ans:
	print(a)


(n, d) = map(int, input().split())
n_kuz = int(input())
for i in range(n_kuz):
	(x, y) = map(int, input().split())
	one = y * (n - d) + x * (d - n) - d * (n - d)
	two = y * d + x * d - d ** 2
	three = y * d + x * d + ((n - d) ** 2 - n ** 2)
	four = y * (n - d) + x * (d - n) + (d * n - d ** 2)
	if one <= 0 and two >= 0 and (three <= 0) and (four >= 0):
		print('YES')
	else:
		print('NO')


import math

def angle(x1, y1, x2, y2, x3, y3):
	a = (x3 - x1) ** 2 + (y3 - y1) ** 2
	b = (x3 - x2) ** 2 + (y3 - y2) ** 2
	c = (x2 - x1) ** 2 + (y2 - y1) ** 2
	return math.acos(round((a + b - c) / (2 * a ** (1 / 2) * b ** (1 / 2)), 9))
(n, d) = [int(s) for s in input().split()]
(x2, y2) = (0, d)
(x1, y1) = (d, 0)
(x4, y4) = (n, n - d)
(x3, y3) = (n - d, n)
amount = int(input())
for i in range(amount):
	(x, y) = [int(s) for s in input().split()]
	if x == x1 and y == y1 or (x == x2 and y == y2) or (x == x3 and y == y3) or (x == x4 and y == y4):
		print('YES')
	elif abs(angle(x1, y1, x2, y2, x, y) + angle(x2, y2, x3, y3, x, y) + angle(x3, y3, x4, y4, x, y) + angle(x4, y4, x1, y1, x, y) - 2 * math.pi) < 1 / 10000000.0:
		print('YES')
	else:
		print('NO')


RawData = input().split(' ')
(n, d) = (int(RawData[0]), int(RawData[1]))
m = int(input())
list = []
for i in range(m):
	RawData = input().split(' ')
	if int(RawData[0]) + int(RawData[1]) < d or int(RawData[0]) + int(RawData[1]) > 2 * n - d:
		list.append(0)
	elif int(RawData[1]) <= int(RawData[0]) + d and int(RawData[1]) >= int(RawData[0]) - d:
		list.append(1)
	else:
		list.append(0)
for i in range(m):
	if list[i] == 0:
		print('NO')
	else:
		print('YES')


import sys

def p(x, intercept):
	return x + intercept
args = sys.stdin.readlines()
(n, d) = args[0].split(' ')
d = d.replace('\n', '')
(n, d) = (int(n), int(d))
grasshoppers = args[2:]
for grasshopper in grasshoppers:
	(x, y) = grasshopper.split(' ')
	y = y.replace('\n', '')
	(x, y) = (int(x), int(y))
	in_side1 = p(-1 * x, d)
	in_side2 = p(x, -1 * d)
	in_side3 = p(-1 * x, n + n - d)
	in_side4 = p(x, d)
	if y >= in_side1 and y >= in_side2 and (y <= in_side3) and (y <= in_side4):
		print('YES')
	else:
		print('NO')


(n, d) = input().split(' ')
n = int(n)
d = int(d)
m = int(input())
list = []
for i in range(m):
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	list.append((x, y))
for l in list:
	(x, y) = l
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + n + n - d):
		print('YES')
	else:
		print('NO')


from math import sqrt
(n, d) = [int(x) for x in input().split()]
grasshopper = int(input())

def line_len(point1, point2):
	p0 = (point2[0] - point1[0]) ** 2
	p1 = (point2[1] - point1[1]) ** 2
	return sqrt(p0 + p1)

def triangle_area(p1, p2, p3):
	u = (p1 + p2 + p3) / 2
	a = u * (u - p1) * (u - p2) * (u - p3)
	area = sqrt(a if a >= 0 else 0)
	return area
[*p] = [(0, d), (d, 0), (n, n - d), (n - d, n)]
[*a] = [line_len(p[0], p[1]), line_len(p[1], p[2]), line_len(p[2], p[3]), line_len(p[3], p[0])]
for _ in range(grasshopper):
	(x, y) = [int(x) for x in input().split()]
	(l1, l2, l3, l4) = (line_len((x, y), p[0]), line_len((x, y), p[1]), line_len((x, y), p[2]), line_len((x, y), p[3]))
	d1 = triangle_area(l1, l2, a[0])
	d2 = triangle_area(l2, l3, a[1])
	d3 = triangle_area(l3, l4, a[2])
	d4 = triangle_area(l4, l1, a[3])
	rec_area = a[0] * a[1]
	new_area = d1 + d2 + d3 + d4
	error = 0.001
	if abs(new_area - rec_area) < error:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
x1 = 0
y1 = d
x2 = d
y2 = 0
x3 = n
y3 = n - d
x4 = n - d
y4 = n
m = int(input())
for i in range(m):
	(a, b) = map(int, input().split())
	dx = x2 - x1
	dy = y2 - y1
	d1 = ((y1 - b) * dx + (a - x1) * dy) / (dy * dy + dx * dx)
	dx = x3 - x2
	dy = y3 - y2
	d2 = ((y2 - b) * dx + (a - x2) * dy) / (dy * dy + dx * dx)
	dx = x4 - x3
	dy = y4 - y3
	d3 = ((y3 - b) * dx + (a - x3) * dy) / (dy * dy + dx * dx)
	dx = x1 - x4
	dy = y1 - y4
	d4 = ((y4 - b) * dx + (a - x4) * dy) / (dy * dy + dx * dx)
	if d1 <= 0 and d2 <= 0 and (d3 <= 0) and (d4 <= 0):
		print('YES')
	else:
		print('NO')


import sys
(n, d) = map(int, input().split())
m = int(input())
a = []
for i in range(m):
	(x, y) = map(int, input().split())
	if d - x - y <= 0 and 2 * n - d - x - y >= 0 and (x - y + d >= 0) and (x - y - d <= 0):
		a.append('YES')
		a.append('\n')
	else:
		a.append('NO')
		a.append('\n')
sys.stdout.write(''.join(a))


list = [int(x) for x in input().split()]
n = list[0]
d = list[1]
intel = int(input())
for i in range(intel):
	l = [int(x) for x in input().split()]
	x = l[0]
	y = l[1]
	if d + x >= y and y >= x - d and (2 * n - d - x >= y) and (d - x <= y):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for _ in range(m):
	(xi, yi) = map(int, input().split())
	print('YES' if xi + yi >= d and xi + yi <= 2 * n - d and (abs(xi - yi) <= d) else 'NO')


(n, d) = map(int, input().split())
m = int(input())
r = 0
l = []
while m != r:
	(a, b) = map(int, input().split())
	r = r + 1
	y1 = d - a
	y2 = 2 * n - d - a
	y3 = a + d
	y4 = a - d
	if y1 < b and y2 > b and (y3 > b) and (y4 < b) or y1 == b or y2 == b or (y3 == b) or (y4 == b):
		l.append('YES')
	else:
		l.append('NO')
for i in l:
	print(i)


a = list(map(int, input().split()))
n = a[0]
d = a[1]
m = int(input())
s = []
for i in range(m):
	s.append(list(map(int, input().split())))
for i in range(m):
	x = s[i][0]
	y = s[i][1]
	if y >= -x + d and y >= x - d and (y <= x + d) and (y <= -x + 2 * n - d):
		print('yes')
	else:
		print('no')


(n, d) = [int(i) for i in input().split()]
m = int(input())
s = []
for i in range(m):
	s.append([int(i) for i in input().split()])
ca1 = d
la1 = 1
ca2 = -d
la2 = 1
cb1 = d
lb1 = -1
cb2 = 2 * n - d
lb2 = -1
for i in s:
	x = i[0]
	y = i[1]
	if y <= ca1 + la1 * x and y <= cb2 + lb2 * x and (y >= ca2 + la2 * x) and (y >= cb1 + lb1 * x):
		print('YES')
	else:
		print('NO')


def square(x1, y1, x2, y2):
	return x1 * y2 - x2 * y1

def is_in(x, y, n, d, v):
	s1 = square(d - x, -y, -x, d - y)
	s2 = square(-x, d - y, n - d - x, n - y)
	s3 = square(n - d - x, n - y, n - x, n - d - y)
	s4 = square(n - x, n - d - y, d - x, -y)
	if s1 <= 0 and s2 <= 0 and (s3 <= 0) and (s4 <= 0) or (s1 >= 0 and s2 >= 0 and (s3 >= 0) and (s4 >= 0)):
		return True
	return False
(n, d) = map(int, input().split())
m = int(input())
v = n - d
for i in range(m):
	animal = list(map(int, input().split()))
	if is_in(animal[0], animal[1], n, d, v):
		print('YES')
	else:
		print('NO')


k = input().split()
(n, d) = (int(k[0]), int(k[1]))
b = 2 * n - d
m = int(input())
for i in range(m):
	k = input().split()
	(x, y) = (int(k[0]), int(k[1]))
	if y <= x + d and y >= x - d and (y >= -x + d) and (y <= -x + b):
		print('YES')
	else:
		print('NO')


(n, d) = [int(x) for x in input().split()]
k = []
for i in range(d + 1):
	for x in range(n - d + 1):
		k.append([x + i, x + d - i])
for i in range(d):
	for x in range(n - d):
		k.append([x + i + 1, x + d - i])
m = int(input())
for i in range(m):
	(xi, yi) = [int(x) for x in input().split()]
	if [xi, yi] in k:
		print('YES')
	else:
		print('NO')


(a, b) = map(int, input().split())
n = int(input())
i = 0
while i < n:
	(x, y) = map(int, input().split())
	if x <= a and y <= a:
		k = [b - y, y + b, y - b, 2 * a - b - y]
		z = 0
		c = 0
		for elem in k:
			if elem <= x and elem >= 0 and (elem <= a):
				z += 1
			if elem >= x and elem >= 0 and (elem <= a):
				c += 1
		if c != 0 and z != 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	i += 1


inp = input().split()
n = int(inp[0])
d = int(inp[1])
k = int(input())
array = []
for i in range(k):
	array += [input().split()]
for i in array:
	if int(i[1]) <= int(i[0]) + d and int(i[1]) >= -int(i[0]) + d and (int(i[1]) <= -int(i[0]) + 2 * n - d) and (int(i[1]) >= int(i[0]) - d):
		print('YES')
	else:
		print('NO')


import math
import sys
inf = 2000000000

class Point:
	(x, y) = (0, 0)

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, vec):
		return Point(self.x + vec.x, self.y + vec.y)

	def __sub__(self, vec):
		self.x -= vec.x
		self.y -= vec.y

	def __str__(self):
		return str(self.x) + ' ' + str(self.y)

	def dist_to_point(self, pA):
		return vector_by_points(self, pA).length()

	def dist_to_line(self, line):
		if math.sqrt(line.a * line.a + line.b * line.b) == 0:
			return inf
		return (self.x * line.a + self.y * line.b + line.c) / math.sqrt(line.a * line.a + line.b * line.b)

	def dist_to_segment(self, pA, pB):
		AB = vector_by_points(pA, pB)
		AC = vector_by_points(pA, self)
		if AB * AC < 0:
			return self.dist_to_point(pA)
		BA = -AB
		BC = vector_by_points(pB, self)
		if BA * BC < 0:
			return self.dist_to_point(pB)
		return abs(self.dist_to_line(line_by_points(pA, pB)))

	def dist_to_ray(self, pA, pB):
		AC = vector_by_points(pA, self)
		AB = vector_by_points(pA, pB)
		if AC * AB < 0:
			return self.dist_to_point(pA)
		return abs(self.dist_to_line(line_by_points(pA, pB)))

class Vector:
	(x, y) = (0, 0)

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def length(self):
		return math.sqrt(self.x * self.x + self.y * self.y)

	def __mul__(self, vec):
		return self.x * vec.x + self.y * vec.y

	def __pow__(self, vec):
		return self.x * vec.y - self.y * vec.x

	def __truediv__(self, x):
		return Vector(self.x / x, self.y / x)

	def __add__(self, vec):
		return Vector(self.x + vec.x, self.y + vec.y)

	def __sub__(self, vec):
		return Vector(self.x - vec.x, self.y - vec.y)

	def __neg__(self):
		return Vector(-self.x, -self.y)

	def __str__(self):
		return str(self.x) + ' ' + str(self.y)

	def normalize(self):
		ln = self.length()
		self.x /= ln
		self.y /= ln

	def to_len(self, x):
		self.normalize()
		self.x *= x
		self.y *= x

	def angle_rad(self, vec):
		angle = math.atan2(self ** vec, self * vec)
		if angle < 0:
			angle += 2 * math.pi
		return angle

	def angle(self, vec):
		return self.angle_rad(vec) / math.pi * 180

	def polar(self):
		return self.angle_rad(Vector(1, 0))

class Line:
	(a, b, c) = (0, 0, 0)

	def __init__(self, a, b, c):
		self.a = a
		self.b = b
		self.c = c

	def __str__(self):
		return str(self.a) + ' ' + str(self.b) + ' ' + str(self.c)

	def normalize(self):
		z = math.sqrt(self.a * self.a + self.b * self.b)
		self.a /= z
		self.b /= z
		self.c /= z

	def intersection(self, ln):
		opred = self.a * ln.b - self.b * ln.a
		opred_x = self.c * ln.b - self.b * ln.c
		opred_y = self.a * ln.c - self.c * ln.a
		x = -opred_x / opred
		y = -opred_y / opred
		return Point(x, y)

def vector_by_points(p1, p2):
	return Vector(p2.x - p1.x, p2.y - p1.y)

def normal_to_line(line):
	return Vector(line.a, line.b)

def line_by_points(p1, p2):
	b = p1.x - p2.x
	a = p2.y - p1.y
	c = -(a * p1.x + b * p1.y)
	return Line(a, b, c)

def segment_intersect(pA, pB, pC, pD):
	AB = vector_by_points(pA, pB)
	AC = vector_by_points(pA, pC)
	AD = vector_by_points(pA, pD)
	CD = vector_by_points(pC, pD)
	CB = vector_by_points(pC, pB)
	CA = -AC
	if AB ** AC * AB ** AD <= 0 and CD ** CB * CD ** CA <= 0 and (min(pC.x, pD.x) <= max(pA.x, pB.x) <= max(pC.x, pD.x) or min(pA.x, pB.x) <= max(pC.x, pD.x) <= max(pA.x, pB.x)):
		return True
	return False

def segment_to_segment(pA, pB, pC, pD):
	if segment_intersect(pA, pB, pC, pD):
		return 0
	mn = min(pA.dist_to_segment(pC, pD), pB.dist_to_segment(pC, pD))
	mn = min(mn, pC.dist_to_segment(pA, pB))
	mn = min(mn, pD.dist_to_segment(pA, pB))
	return mn

def ray_to_ray(pA, pB, pC, pD):
	pt = line_by_points(pA, pB).intersection(line_by_points(pC, pD))
	if pt.dist_to_ray(pA, pB) == 0 and pt.dist_to_ray(pC, pD) == 0:
		return 0
	return min(pA.dist_to_ray(pC, pD), pC.dist_to_ray(pA, pB))

def area(a):
	prev = Vector(a[-1].x, a[-1].y)
	ans = 0
	for pt in a:
		cur = Vector(pt.x, pt.y)
		ans += prev ** cur / 2
		prev = cur
	return abs(ans)
(n, d) = map(int, input().split())
field = [Point(0, d), Point(d, 0), Point(n, n - d), Point(n - d, n)]
s = area(field)
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	cur = Point(x, y)
	ar = area([field[0], field[1], cur]) + area([field[1], field[2], cur]) + area([field[2], field[3], cur]) + area([field[3], field[0], cur])
	if ar == s:
		print('YES')
	else:
		print('NO')


(n, d) = (int(e) for e in input().split(' '))
for i in range(int(input())):
	(x, y) = (int(e) for e in input().split(' '))
	(d1, d2) = (x - y, x + y)
	if -d <= d1 <= d and d <= d2 <= n - d + n:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, d) = list(map(int, input().split()))
for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	a = y - x
	b = y + x
	if a < d and a > -d and (b > d) and (b < 2 * n - d):
		print('YES')
	elif a == d or a == -d or b == d or (b == 2 * n - d):
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())
for i in range(m):
	(x, y) = map(int, input().split())
	if x + y < d:
		print('NO')
		continue
	if x + y > 2 * n - d:
		print('NO')
		continue
	if n - x + y < n - d:
		print('NO')
		continue
	if n - y + x < n - d:
		print('NO')
		continue
	print('YES')


import math

def main():
	(n, d) = map(int, input().split())
	m = int(input())
	a = range(d, 2 * n - d + 1)
	b = range(-d, d + 1)
	for i in range(m):
		(x, y) = map(int, input().split())
		if x - y in b and x + y in a:
			print('YES')
		else:
			print('NO')
main()


(n, d) = map(int, input().split())
m = int(input())
otv = []
for i in range(m):
	(x, y) = map(int, input().split())
	if y >= -x + d and y <= -x + n + n - d and (y >= x - d) and (y <= x + d):
		otv.append('YES')
	else:
		otv.append('NO')
print('\n'.join(otv))


(n, d) = list(map(int, input().split()))
for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	print('YES' if x + y in range(d, n + n - d + 1) and x - y in range(-d, d + 1) else 'NO')


(n, d) = map(int, input().split())
m = int(input())
a = [0] * m
b = [0] * m

def fun(x, y):
	if x + y >= d and x + y <= 2 * n - d and (abs(y - x) <= d):
		return 1
	else:
		return 0
for i in range(0, m):
	(x, y) = map(int, input().split())
	a[i] = x
	b[i] = y
for i in range(0, m):
	if fun(a[i], b[i]):
		print('YES')
	else:
		print('NO')


from math import *
(n, d) = map(int, input().split())
m = int(input())
A = []
for i in range(m):
	(a, b) = map(int, input().split())
	if b >= abs(a - d) and b <= n - abs(a - n + d):
		A.append(1)
	else:
		A.append(0)
for j in range(m):
	if A[j] == 1:
		print('YES')
	else:
		print('NO')


(n, d) = map(int, input().split())
m = int(input())

def vp(x1, y1, x2, y2):
	return x1 * y2 - x2 * y1

def isWithin(x, y):
	return vp(n - d, n - d, x - d, y) >= 0 and vp(x - d, y, -d, d) >= 0 and (vp(x, y - d, n - d, n - d) >= 0) and (vp(-d, d, x - n, y - n + d) >= 0)
for i in range(m):
	(x, y) = map(int, input().split())
	print('YES' if isWithin(x, y) else 'NO')