#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll h,w,n;cin>>h>>w>>n;
    vector<pll> v[4];
    rep(i,0,n){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        if(a==0){
            if(c==0){
                v[0].push_back({b,i});
                v[0].push_back({d,i});
            }
            else if(d==0){
                v[0].push_back({b,i});
                v[3].push_back({c,i});
            }
            else if(c==h){
                v[0].push_back({b,i});
                v[2].push_back({d,i});
            }
            else if(d==w){
                v[0].push_back({b,i});
                v[1].push_back({c,i});
            }
        }
        else if(a==h){
            if(c==0){
                v[2].push_back({b,i});
                v[0].push_back({d,i});
            }
            else if(d==0){
                v[2].push_back({b,i});
                v[3].push_back({c,i});
            }
            else if(c==h){
                v[2].push_back({b,i});
                v[2].push_back({d,i});
            }
            else if(d==w){
                v[2].push_back({b,i});
                v[1].push_back({c,i});
            }
        }
        else if(b==0){
            if(c==0){
                v[3].push_back({a,i});
                v[0].push_back({d,i});
            }
            else if(d==0){
                v[3].push_back({a,i});
                v[3].push_back({c,i});
            }
            else if(c==h){
                v[3].push_back({a,i});
                v[2].push_back({d,i});
            }
            else if(d==w){
                v[3].push_back({a,i});
                v[1].push_back({c,i});
            }
        }
        else if(b==w){
            if(c==0){
                v[1].push_back({a,i});
                v[0].push_back({d,i});
            }
            else if(d==0){
                v[1].push_back({a,i});
                v[3].push_back({c,i});
            }
            else if(c==h){
                v[1].push_back({a,i});
                v[2].push_back({d,i});
            }
            else if(d==w){
                v[1].push_back({a,i});
                v[1].push_back({c,i});
            }
        }
    }
    rep(i,0,4)sort(v[i].begin(),v[i].end());
   
    deque<ll> dq;
    int y=0;
    bool used[n];
    fill(used,used+n,false);
    rep(i,0,4){
        if(i>=2)reverse(v[i].begin(),v[i].end());
        rep(j,0,v[i].size()){
            ll num=v[i][j].second;
           // cout<<num<<" ";
            if(used[num]==false){
                dq.push_back(num);
                used[num]=true;
            }
            else{
                if(dq.back()!=num){
                    y=1;
                    break;
                }
                dq.pop_back();
                used[num]=false;
            }
        }
        //if(y)break;
    }
    if(y)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}




Measured memory_bytes: 4944