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

int W,H,N;
vector<pair<int,int>>a;

int main(){
	cin>>W>>H>>N;
	for(int i=1;i<=N;++i){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(x1==0|x1==W|y1==0|y1==H && x2==0|x2==W|y2==0|y2==H){
			for(int j=0;j<2;++j){
				if(y1==0){
					a.push_back({x1,i});
				}else if(x1==W){
					a.push_back({W+y1,i});
				}else if(y1==H){
					a.push_back({W+H+W-x1,i});
				}else if(x1==0){
					a.push_back({W+H+W+H-y1,i});
				}
				x1=x2;
				y1=y2;
			}
		}
	}
	sort(a.begin(),a.end());
	int s[100000],i=0;
	bool d[100001]={false};
	for(auto b:a){
		int j=b.second;
		if(d[j]){
			if(s[--i]!=j){
				cout<<"NO";
				return 0;
			}
		}else{
			d[j]=true;
			s[i++]=j;
		}
	}
	cout<<"YES";
}
