// https://arc076.contest.atcoder.jp/tasks/arc076_c
#include<iostream>
#include<vector>
#include<algorithm>

#ifdef _GLIBCXX_DEBUG
#define cin cin_
#include<sstream>
namespace std{std::stringstream cin(R"(
1 1 2
0 0 1 1
1 0 0 1
)");}
#endif

int r,c;
int process(int x,int y){
	if(y==0)return x;
	if(x==r)return r+y;
	if(y==c)return r+c+(r-x);
	if(x==0)return r+c+r+(c-y);
	return -1;
}

int main(){
	std::ios::sync_with_stdio(false);std::cin.tie(nullptr);

	int n;std::cin>>r>>c>>n;
	struct data{int pos,id;bool close;};
	std::vector<data>lines;lines.reserve(n);
	for(int id=0;id<n;++id){
		int x1,y1,x2,y2;std::cin>>x1>>y1>>x2>>y2;
		int p1=process(x1,y1);
		int p2=process(x2,y2);
		if(p1<0||p2<0)continue;
		lines.push_back({std::min(p1,p2),id,false}); // not close
		lines.push_back({std::max(p1,p2),id,true }); // close
	}
	std::sort(lines.begin(),lines.end(),[](data x,data y){return x.pos<y.pos;});
	std::vector<int>stack;
	for(auto x:lines){
		if(x.close){
			if(stack.back()!=x.id){std::cout<<"NO\n";return 0;}
			stack.pop_back();
		}else
			stack.push_back(x.id);
	}
	std::cout<<"YES\n";
}
