#include <bits/stdc++.h>
 
using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
typedef uint64_t ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const ll mod = 1e9+7;
 
 
int r,c,n;
 
 
ll fz(int y, int x){
	if(x ==0) return 0 + y;
	if(y ==r) return r + x;
	if(x ==c) return r+c+r - y;
	if(y ==0) return r+c+r+c - x;
	return -1;
}
 
int main()
{
	
	vector<pair<ll,int>> vp;
	//cin.tie(0); ios_base::sync_with_stdio(false);
	cin >>c >>r >>n;
 
	rep(i,n){
	
		int ar,ac,br,bc;
		cin >>ac >>ar >>bc >>br;
	
		ll aa = fz(ar, ac);
		ll bb = fz(br, bc);
	
		if(aa ==-1 || bb ==-1) continue;
		vp.emplace_back(aa, i);
		vp.emplace_back(bb, i);
	}
	
	sort(all(vp));
	//for(auto x: vp) printf("%lld:%d ",x.first,x.second);puts("");
	
	stack<int> stc;
	for(auto x: vp){
		if(!stc.empty() && stc.top() == x.second) stc.pop();
		else stc.push(x.second);
	}
	
	cout <<(stc.empty()? "YES":"NO") <<"\n";
	return 0;
}