#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define maxn 1000002
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
int a[maxn][2][2];
vii top,bottom,lt,rt;
int onStack[maxn];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    int r,c,n;
    cin>>r>>c>>n;
    swap(r,c);
    rep (i,0,n) {
        cin>>a[i][0][0]>>a[i][0][1]>>a[i][1][0]>>a[i][1][1];
        int good=0;
        int x1 = a[i][0][0],y1=a[i][0][1];
        int x2 = a[i][1][0],y2=a[i][1][1];
        if ((x1==0 || x1==c || y1==r || y1==0)&& (x2==0 || x2==c || y2==r || y2==0))
        rep (j,0,2) {
                int x = a[i][j][0];
                int y = a[i][j][1];
                if (x==0) lt.push_back(mp(y,i+j*n));
                else if (x==c)rt.push_back(mp(y,i+j*n));
                else if (y==0) bottom.push_back(mp(x,i+j*n));
                else if (y==r)top.push_back(mp(x,i+j*n));

            }

    }

    sort(all(top));
    sort(all(rt));
    reverse(all(rt));
    sort(all(bottom));
    reverse(all(bottom));
    sort(all(lt));
    stack<int> s;
    rep (i,0,top.size()) {

        int id = top[i].second;
        if (id<n) {
            id+=n;
        }
            if (onStack[id-n] && s.top()!=id-n) {
                cout<<"NO";
                return 0;
            } else if (onStack[id-n] && s.top()==id-n) {
                s.pop();

            }
            if (!onStack[id-n]) {
                onStack[id-n] = true;
                s.push(id-n);

            }


    }
    rep (i,0,rt.size()) {

        int id = rt[i].second;
        if (id<n) {
            id+=n;
        }
        if (onStack[id-n] && s.top()!=id-n) {
            cout<<"NO";
            return 0;
        } else if (onStack[id-n] && s.top()==id-n) {
            s.pop();

        }
        if (!onStack[id-n]) {
            onStack[id-n] = true;
            s.push(id-n);

        }


    }
    rep (i,0,bottom.size()) {

        int id = bottom[i].second;
        if (id<n) {
            id+=n;
        }
        if (onStack[id-n] && s.top()!=id-n) {
            cout<<"NO";
            return 0;
        } else if (onStack[id-n] && s.top()==id-n) {
            s.pop();

        }
        if (!onStack[id-n]) {
            onStack[id-n] = true;
            s.push(id-n);

        }


    }
    rep (i,0,lt.size()) {

        int id = lt[i].second;
        if (id<n) {
            id+=n;
        }
        if (onStack[id-n] && s.top()!=id-n) {
            cout<<"NO";
            return 0;
        } else if (onStack[id-n] && s.top()==id-n) {
            s.pop();

        }
        if (!onStack[id-n]) {
            onStack[id-n] = true;
            s.push(id-n);

        }


    }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 6680