# coding: utf-8

# Your code here!



import sys

sys.setrecursionlimit(10**6)

readline = sys.stdin.readline #文字列入力のときは注意





r,c,n = [int(i) for i in readline().split()]

#xyxy = [[int(i) for i in readline().split()] for _ in range(n)] 

#for i,(x1,y1,x2,y2) in enumerate(xyxy):



def addedge(x1,y1):

    if   y1 == 0:

        edge.append((x1,i))

    elif x1 == r:

        edge.append((r+y1,i))

    elif y1 == c:

        edge.append((r+c+(r-x1),i))

    else:

        edge.append((r+c+r+(c-y1),i))

    return 





edge = []

for i in range(n):

    x1,y1,x2,y2 = [int(i) for i in readline().split()]

    if (x1 not in (0,r) and y1 not in (0,c)) or (x2 not in (0,r) and y2 not in (0,c)):

        continue

    

    addedge(x1,y1)

    addedge(x2,y2)



        

edge.sort()

#print(edge)



ans = []

for d,i in edge:

    if ans and ans[-1] == i:

        ans.pop()

    else:

        ans.append(i)



if ans:

    print("NO")

else:

    print("YES")

    





    









# coding: utf-8

# Your code here!

import sys

read = sys.stdin.read

readline = sys.stdin.readline



h,w,n, *xyxy = list(map(int,read().split()))



def f(x,y):

    if y==0: return x

    elif x==h: return h+y

    elif y==w: return h+w+h-x

    else: return h+w+h+w-y    



m = iter(xyxy)

res = []

idx = 0

for x1,y1,x2,y2 in zip(m,m,m,m):

    if (x1*(h-x1)==0 or y1*(w-y1)==0) and (x2*(h-x2)==0 or y2*(w-y2)==0):

        res.append((f(x1,y1),idx))

        res.append((f(x2,y2),idx))

        idx += 1





res.sort()

#print(res)



st = []

for d,i in res:

    if st and st[-1] == i:

        st.pop()

    else:

        st.append(i)



if st:

    print("NO")

else:

    print("YES")



















# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline  # 文字列入力のときは注意
r, c, n = [int(i) for i in readline().split()]
# xyxy = [[int(i) for i in readline().split()] for _ in range(n)]
# for i,(x1,y1,x2,y2) in enumerate(xyxy):
def addedge(x1, y1):
    if y1 == 0:
        edge.append((x1, i))
    elif x1 == r:
        edge.append((r + y1, i))
    elif y1 == c:
        edge.append((r + c + (r - x1), i))
    else:
        edge.append((r + c + r + (c - y1), i))
    return


edge = []
for i in range(n):
    x1, y1, x2, y2 = [int(i) for i in readline().split()]
    if (x1 not in (0, r) and y1 not in (0, c)) or (
        x2 not in (0, r) and y2 not in (0, c)
    ):
        continue
    addedge(x1, y1)
    addedge(x2, y2)
edge.sort()
# print(edge)
ans = []
for d, i in edge:
    if ans and ans[-1] == i:
        ans.pop()
    else:
        ans.append(i)
if ans:
    print("NO")
else:
    print("YES")

# coding: utf-8
# Your code here!
import sys

read = sys.stdin.read
readline = sys.stdin.readline
h, w, n, *xyxy = list(map(int, read().split()))


def f(x, y):
    if y == 0:
        return x
    elif x == h:
        return h + y
    elif y == w:
        return h + w + h - x
    else:
        return h + w + h + w - y


m = iter(xyxy)
res = []
idx = 0
for x1, y1, x2, y2 in zip(m, m, m, m):
    if (x1 * (h - x1) == 0 or y1 * (w - y1) == 0) and (
        x2 * (h - x2) == 0 or y2 * (w - y2) == 0
    ):
        res.append((f(x1, y1), idx))
        res.append((f(x2, y2), idx))
        idx += 1
res.sort()
# print(res)
st = []
for d, i in res:
    if st and st[-1] == i:
        st.pop()
    else:
        st.append(i)
if st:
    print("NO")
else:
    print("YES")

-sys.setrecursionlimit(10**6) -readline = sys.stdin.readline  # 文字列入力のときは注意 -r, c, n = [int(i) for i in readline().split()] -# xyxy = [[int(i) for i in readline().split()] for _ in range(n)] -# for i,(x1,y1,x2,y2) in enumerate(xyxy): -def addedge(x1, y1): -    if y1 == 0: -        edge.append((x1, i)) -    elif x1 == r: -        edge.append((r + y1, i)) -    elif y1 == c: -        edge.append((r + c + (r - x1), i)) -    else: -        edge.append((r + c + r + (c - y1), i)) -    return +read = sys.stdin.read +readline = sys.stdin.readline +h, w, n, *xyxy = list(map(int, read().split())) -edge = [] -for i in range(n): -    x1, y1, x2, y2 = [int(i) for i in readline().split()] -    if (x1 not in (0, r) and y1 not in (0, c)) or ( -        x2 not in (0, r) and y2 not in (0, c) +def f(x, y): +    if y == 0: +        return x +    elif x == h: +        return h + y +    elif y == w: +        return h + w + h - x +    else: +        return h + w + h + w - y + + +m = iter(xyxy) +res = [] +idx = 0 +for x1, y1, x2, y2 in zip(m, m, m, m): +    if (x1 * (h - x1) == 0 or y1 * (w - y1) == 0) and ( +        x2 * (h - x2) == 0 or y2 * (w - y2) == 0 -        continue -    addedge(x1, y1) -    addedge(x2, y2) -edge.sort() -# print(edge) -ans = [] -for d, i in edge: -    if ans and ans[-1] == i: -        ans.pop() +        res.append((f(x1, y1), idx)) +        res.append((f(x2, y2), idx)) +        idx += 1 +res.sort() +# print(res) +st = [] +for d, i in res: +    if st and st[-1] == i: +        st.pop() -        ans.append(i) -if ans: +        st.append(i) +if st: