#include <algorithm>
#include <iostream>
#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#define FORI(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)

bool debug = false;
#define DEBUG if(debug)

const int INF = 2000000000;

// 便利関数 {{{
template <typename T>
int indexOf(const vector<T> &v, T elem)
{
  auto iter = std::find(v.begin(), v.end(), elem);
  size_t idx = std::distance(v.begin(), iter);
  if (idx == v.size()) return -1;
  return idx;
}

template <typename T>
void println(const T &msg)
{
  std::cout << msg << endl;
}

// http://blog.madhukaraphatak.com/functional-programming-in-c++/
template <typename Collection, typename unop>
Collection map(const Collection &src, unop op)
{
  Collection dst(src.size());
  std::transform(src.begin(), src.end(), dst.begin(), op);
  return dst;
}

template <typename Collection, typename binop>
Collection zip(const Collection &src1, const Collection &src2)
{
  auto op = [](typename Collection::value_type e1, typename Collection::value_type e2) {
    return make_tuple(e1, e2);
  };
  return zipWith(src1, src2, op);
}

template <typename Collection, typename binop>
Collection &zipWith(const Collection &src1, const Collection &src2, binop op)
{
  Collection dst(src1.size());
  std::transform(src1.begin(), src1.end(), src2.begin(), dst.begin(), op);
  return dst; // undefined!
}

template <typename Collection,typename Predicate>
Collection &filter(const Collection &src, Predicate pred)
{
  Collection dst;
  std::copy_if(src.begin(), src.end(), std::back_inserter(dst), pred);
  return dst;
}
// }}}

// const int MAX_R=(int)1e8,MAX_C=(int)1e8;
const int MAX_N=(int)1e5;
int r,c,n,x1[MAX_N],y1[MAX_N],x2[MAX_N],y2[MAX_N];

template <typename T>
void sort_with(std::vector<T> &v1, std::vector<T> &v2)
{
  std::vector<int> indices(v1.size());
  std::iota(indices.begin(), indices.end(), 0);
  std::sort(indices.begin(), indices.end(), [&](int l, int r) {
      return v1[l] < v1[r];
  });

  std::vector<T> v1_sorted(v1.size()), v2_sorted(v1.size());
  for (size_t i = 0; i < v1.size(); i++) {
    v1_sorted[i] = v1[indices[i]];
    v2_sorted[i] = v2[indices[i]];
  }
  std::swap(v1, v1_sorted);
  std::swap(v2, v2_sorted);
}

int main(int argc, char const*[])
{
  if(argc > 1) debug = true;

  cin>>r>>c>>n;
  FORI(n)cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];

  /*
  vector<int> v;
  FORI(n){
    // 同じ数字の点がそれぞれ異なる辺上にある
    if((x1[i]==0||x1[i]==r||y1[i]==0||y1[i]==c)
        &&(x2[i]==0||x2[i]==r||y2[i]==0||y2[i]==c)
        // 同じ辺上にある場合は除く
        &&(!((x1[i]==0&&x2[i]==0)||(x1[i]==r&&x2[i]==r)
            ||(y1[i]==0&&y2[i]==0)||(y1[i]==c&&y2[i]==c)))){
      v.push_back(i);
      DEBUG println(i);
    }
  }

  bool ok=true;
  FORI(n){
    for(int j:v){
      if(i==j)continue;
      auto cond = [j](int x, int y) {
        if(x1[j]!=x2[j])
          return y > (x-x1[j])*(y1[j]-y2[j])/(x1[j]-x2[j])+y1[j];
        else
          return x > x1[j];
      };

      // 同じ数字の点が，数直線の上下にある
      if(cond(x1[i], y1[i])!=cond(x2[i],y2[i]))ok=false;
    }
  }

  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  */

  // auto hen=vector<int>(r*2+c*2, -1);
  vector<int> hen,hen_num;

  FORI(n){
    // 同じ数字の点がどちらも辺上にある
    if((x1[i]==0||x1[i]==r||y1[i]==0||y1[i]==c)
        &&(x2[i]==0||x2[i]==r||y2[i]==0||y2[i]==c)){
      DEBUG println(i);

      // 4辺を伸ばした線上に置く
      // if(x1[i]==0)hen[2*r+c+c-y1[i]]=i;
      // if(x1[i]==r)hen[r+y1[i]]=i;
      // if(y1[i]==0)hen[x1[i]]=i;
      // if(y1[i]==c)hen[r+c+r-x1[i]]=i;
      // if(x2[i]==0)hen[2*r+c+c-y2[i]]=i;
      // if(x2[i]==r)hen[r+y2[i]]=i;
      // if(y2[i]==0)hen[x2[i]]=i;
      // if(y2[i]==c)hen[r+c+r-x2[i]]=i;

      if(x1[i]==0)hen.push_back(2*r+c+c-y1[i]);
      else if(x1[i]==r)hen.push_back(r+y1[i]);
      else if(y1[i]==0)hen.push_back(x1[i]);
      else if(y1[i]==c)hen.push_back(r+c+r-x1[i]);
      hen_num.push_back(i);
      if(x2[i]==0)hen.push_back(2*r+c+c-y2[i]);
      else if(x2[i]==r)hen.push_back(r+y2[i]);
      else if(y2[i]==0)hen.push_back(x2[i]);
      else if(y2[i]==c)hen.push_back(r+c+r-x2[i]);
      hen_num.push_back(i);
    }
  }

  sort_with(hen,hen_num);

  // auto v=vector<int>();
  auto s=stack<int>();
  // FORI(hen.size()){
  //   // if(hen[i]!=-1)v.push_back(hen[i]);
  //   if(hen[i]!=-1){
  //     if(!s.empty()&& s.top()==hen[i])s.pop();
  //     else s.push(hen[i]);
  //   }
  // }

  FORI(hen.size()){
    if(!s.empty()&& s.top()==hen_num[i])s.pop();
    else s.push(hen_num[i]);
  }
  if(s.empty())cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  // bool ok=true;
  // FORI(v.size()-1){
  //   if(i==0&&v[i+1]!=v[i]){
  //     DEBUG println("continue");
  //     continue;
  //   }
  //   if(v[i+1]==v[i])i++;//一つスキップ
  //   else {
  //     ok=false;
  //     DEBUG println("ok=false");
  //     break;
  //   }
  // }

  // if(ok)cout<<"YES"<<endl;
  // else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 5996