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: interview

Starter code:

Solutions:
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())
for i in range(m):
    x, y = map(int, input().split())
    if (abs(y - x) <= d and x + y >= d and x + y <= 2 * n - d):
        print("YES")
    else:
        print("NO")

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


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



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")

        


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()]
    if y <= x + d and y <= -1 * x + n - d + n and y >= x - d and y >= -1 * x + 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):  # point + VECTOR
        return Point(self.x + vec.x, self.y + vec.y)

    def __sub__(self, vec):  # point - VECTOR
        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:  # this means angle CAB > 90
            return self.dist_to_point(pA)
        BA = -AB
        BC = vector_by_points(pB, self)
        if BA * BC < 0:  # this means angle CBA > 90
            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):  # |vector|
        return math.sqrt(self.x * self.x + self.y * self.y)

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

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

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

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

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

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

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

    def normalize(self):  # vector / |vector|
        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):  # does AB intersect CD?
    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):  # a is list of Points (shape not necessary convex)
    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')

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])


n,d=list(map(int,input().split()))
N=int(input())
for i in range(N):
    x,y=list(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')



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')

"""
7 2
4
2 4
4 1
6 3
4 5

YES
NO
NO
YES

"""

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")

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

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


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')

#(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 (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())
for i in range(m):
    x, y = [int(i) for i in input().split()]
    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 = 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 = 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 + y) > n * 2 - d:
        print("NO")
    elif abs(x - y) > d:
        print("NO")
    else:
        print("YES")

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

for _ in range(m):
    x, y = list(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")


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


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=list(map(int,input().split()))
m=int(input())
for i in range(m):
    x,y=list(map(int,input().split()))
    if(x<0 or y<0 or x>n or y>n or x+y<d or y+n-x<n-d or n-y+x<n-d or n+n-x-y<d):
        print("NO")
    else:
        print("YES")