#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 R,C,N;
    cin >> R >> C >> N;

    vector<i64> x1,y1,x2,y2;
    rep(i,0,N){
        i64 x1_,y1_,x2_,y2_;
        cin >> x1_ >> y1_ >> x2_ >> y2_;
        if((0<x1_ and x1_<R and 0<y1_ and y1_<C) or (0<x2_ and x2_<R and 0<y2_ and y2_<C)) continue;
        x1.push_back(x1_);
        y1.push_back(y1_);
        x2.push_back(x2_);
        y2.push_back(y2_);
    }

    i64 count=0;

    function<bool(vector<i64>,vector<i64>,vector<i64>,vector<i64>)> rec=[&](vector<i64> x1,vector<i64> y1,vector<i64> x2,vector<i64> y2){
        i64 N=x1.size();
        if(N<=1) return true;
        vector<i64> x11,y11,x12,y12,
                    x21,y21,x22,y22;
        
        i64 m;
        if(count==0) m=0;
        if(count==1) m=N-1;
        if(count==2) m=N/2;
        count=(count+1)%3;

        rep(i,0,N){
            if(i==m) continue;
            i64 p1,q1,p2,q2;
            {
                i64 x=x1[i],y=y1[i];
                for(;;){
                    if(x==0){
                        if((x1[m]==0 and y<=y1[m]) and (x2[m]==0 and y<=y2[m])) y=min(y1[m],y2[m]);
                        else if(x1[m]==0 and y<=y1[m]) y=y1[m];
                        else if(x2[m]==0 and y<=y2[m]) y=y2[m];
                        else y=C;
                    }
                    if(y==C){
                        if((y1[m]==C and x<=x1[m]) and (y2[m]==C and x<=x2[m])) x=min(x1[m],x2[m]);
                        else if(y1[m]==C and x<=x1[m]) x=x1[m];
                        else if(y2[m]==C and x<=x2[m]) x=x2[m];
                        else x=R;
                    }
                    if(x==R){
                        if((x1[m]==R and y>=y1[m]) and (x2[m]==R and y>=y2[m])) y=max(y1[m],y2[m]);
                        else if(x1[m]==R and y>=y1[m]) y=y1[m];
                        else if(x2[m]==R and y>=y2[m]) y=y2[m];
                        else y=0;
                    }
                    if(y==0){
                        if((y1[m]==0 and x>=x1[m]) and (y2[m]==0 and x>=x2[m])) x=max(x1[m],x2[m]);
                        else if(y1[m]==0 and x>=x1[m]) x=x1[m];
                        else if(y2[m]==0 and x>=x2[m]) x=x2[m];
                        else x=0;
                    }
                    if((x==x1[m] and y==y1[m]) or (x==x2[m] and y==y2[m])){
                        p1=x;
                        q1=y;
                        break;
                    }
                }
            }
            {
                i64 x=x2[i],y=y2[i];
                for(;;){
                    if(x==0){
                        if((x1[m]==0 and y<=y1[m]) and (x2[m]==0 and y<=y2[m])) y=min(y1[m],y2[m]);
                        else if(x1[m]==0 and y<=y1[m]) y=y1[m];
                        else if(x2[m]==0 and y<=y2[m]) y=y2[m];
                        else y=C;
                    }
                    if(y==C){
                        if((y1[m]==C and x<=x1[m]) and (y2[m]==C and x<=x2[m])) x=min(x1[m],x2[m]);
                        else if(y1[m]==C and x<=x1[m]) x=x1[m];
                        else if(y2[m]==C and x<=x2[m]) x=x2[m];
                        else x=R;
                    }
                    if(x==R){
                        if((x1[m]==R and y>=y1[m]) and (x2[m]==R and y>=y2[m])) y=max(y1[m],y2[m]);
                        else if(x1[m]==R and y>=y1[m]) y=y1[m];
                        else if(x2[m]==R and y>=y2[m]) y=y2[m];
                        else y=0;
                    }
                    if(y==0){
                        if((y1[m]==0 and x>=x1[m]) and (y2[m]==0 and x>=x2[m])) x=max(x1[m],x2[m]);
                        else if(y1[m]==0 and x>=x1[m]) x=x1[m];
                        else if(y2[m]==0 and x>=x2[m]) x=x2[m];
                        else x=0;
                    }
                    if((x==x1[m] and y==y1[m]) or (x==x2[m] and y==y2[m])){
                        p2=x;
                        q2=y;
                        break;
                    }
                }
            }
            if(p1!=p2 or q1!=q2) return false;
            if(p1==x1[m] and q2==y1[m]){
                x11.push_back(x1[i]);
                y11.push_back(y1[i]);
                x12.push_back(x2[i]);
                y12.push_back(y2[i]);
            }else{
                x21.push_back(x1[i]);
                y21.push_back(y1[i]);
                x22.push_back(x2[i]);
                y22.push_back(y2[i]);
            }
        }
        assert(x11.size()+x21.size()==N-1);
        return rec(x11,y11,x12,y12) and rec(x21,y21,x22,y22);
    };

    if(rec(x1,y1,x2,y2)) cout << "YES" << endl;
    else cout << "NO" << endl;
    /*
    vector<i64> x1(N),y1(N),x2(N),y2(N);
    //vector<pair<i64,i64>> xi1,xi2;
    rep(i,0,N){
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        //if((0<x1[i] and x1[i]<R) or (0<y1[i] and y1[i]<C) or (0<x2[i] and x2[i]<R) or (0<y2[i] and y2[i]<C)) continue;
        if(x1[i]==0 or x1[i]==R) x1[i]=0;
        if(x2[i]==0 or x2[i]==R) x2[i]=0;
        xi1.push_back(make_pair(x1[i],i));
        xi2.push_back(make_pair(x2[i],i));
    }
    */
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 154864