#define _GLIBCXX_IOSTREAM
#include<bits/stdc++.h>
#define maxn 500100
using namespace std;
typedef pair<int,int> par;
struct point{
	int x1,y1,x2,y2;
	point(){}
	void scan(){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	}
}p[maxn];
int n,r,c,sta[maxn],tp;
vector<par> v;
int getid(int x,int y){
	if(x==0)return y;
	if(y==c)return x+c;
	if(x==r)return c-y+r+c;
	if(y==0)return r-x+c+c+r;
	return -1;
}
int main(){
	scanf("%d%d%d",&r,&c,&n);
	for(int i=1;i<=n;++i)p[i].scan();
	for(int i=1;i<=n;++i){
		if(!(p[i].x1==0||p[i].x1==r||p[i].y1==0||p[i].y1==c)||!(p[i].x2==0||p[i].x2==r||p[i].y2==0||p[i].y2==c))continue;
		int x=getid(p[i].x1,p[i].y1),y=getid(p[i].x2,p[i].y2);
		if(x>y)swap(x,y);
		v.push_back(par(x,i));
		v.push_back(par(y,-i));
//		printf("{%d,%d(%d,%d,%d,%d)}\n",getid(p[i].x1,p[i].y1),getid(p[i].x2,p[i].y2),p[i].x1,p[i].y1,p[i].x2,p[i].y2);
	}
	sort(v.begin(),v.end());
	for(auto p:v){
		if(p.second>0)sta[++tp]=p.second;
		else if(sta[tp]!=-p.second)return puts("NO"),0;
		else tp--;
	}
	puts("YES");
}