#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
constexpr double EPS = 1e-10;

struct Point {
  double x, y;
  constexpr Point () : x(0.), y(0.) {}
  template <typename T, typename U> constexpr Point (const T& _x, const U& _y) : x(_x), y(_y) {}
  constexpr Point (const Point& p) : x(p.x), y(p.y) {}
  template <typename T> constexpr Point (const pair<T, T>& p) : x(static_cast<double>(p.first)), y(static_cast<double>(p.second)) {}

  constexpr Point& operator= (const Point& other) & noexcept { this->x = other.x; this->y = other.y; return *this; }
  template <typename T> constexpr Point& operator= (const pair<T, T>& other) & noexcept { return *this = Point(other); }

  constexpr Point& operator+= (const Point& other) noexcept { this->x += other.x; this->y += other.y; return *this; }
  template <typename T> constexpr Point& operator+= (const pair<T, T>& other) noexcept { return *this += Point(other); }

  constexpr Point& operator-= (const Point& other) noexcept { this->x -= other.x; this->y -= other.y; return *this; }
  template <typename T> constexpr Point& operator-= (const pair<T, T>& other) noexcept { return *this -= Point(other); }

  template <typename T> Point& operator*= (const T& other) noexcept {double val = static_cast<double>(other); this->x *= val; this->y *= val; return *this; }
  
  template <typename T> Point& operator/= (const T& other) noexcept {double val = static_cast<double>(other); this->x /= val; this->y /= val; return *this; }

  friend constexpr bool operator== (const Point& lhs, const Point& rhs) noexcept {return lhs.x == rhs.x && lhs.y == rhs.y; }
  template <typename T> friend constexpr bool operator== (const Point& lhs, const pair<T, T>& rhs) noexcept {return lhs.x == rhs.first && lhs.y == rhs.second; }
  template <typename T> friend constexpr bool operator== (const pair<T, T>& lhs, const Point& rhs) noexcept {return lhs.first == rhs.x && lhs.second == rhs.y; }

  friend constexpr bool operator!= (const Point& lhs, const Point& rhs) noexcept {return !(lhs == rhs); }
  template <typename T> friend constexpr bool operator!= (const Point& lhs, const pair<T, T>& rhs) noexcept {return !(lhs == rhs); }
  template <typename T> friend constexpr bool operator!= (const pair<T, T>& lhs, const Point& rhs) noexcept {return !(lhs == rhs); }

  friend constexpr bool operator< (const Point& lhs, const Point& rhs) noexcept {return (abs(lhs.x - rhs.x) > EPS ? lhs.x < rhs.x : lhs.y < rhs.y); }
  template <typename T> friend constexpr bool operator< (const Point& lhs, const pair<T, T>& rhs) noexcept {return lhs < Point(rhs); }
  template <typename T> friend constexpr bool operator< (const pair<T, T>& lhs, const Point& rhs) noexcept {return Point(lhs) < rhs; }

  friend constexpr bool operator> (const Point& lhs, const Point& rhs) noexcept {return (abs(lhs.x - rhs.x) > EPS ? lhs.x > rhs.x : lhs.y > rhs.y); }
  template <typename T> friend constexpr bool operator> (const Point& lhs, const pair<T, T>& rhs) noexcept {return lhs > Point(rhs); }
  template <typename T> friend constexpr bool operator> (const pair<T, T>& lhs, const Point& rhs) noexcept {return Point(lhs) > rhs; }

  friend constexpr bool operator<= (const Point& lhs, const Point& rhs) noexcept {return !(lhs > rhs); }
  template <typename T> friend constexpr bool operator<= (const Point& lhs, const pair<T, T>& rhs) noexcept {return !(lhs > Point(rhs)); }
  template <typename T> friend constexpr bool operator<= (const pair<T, T>& lhs, const Point& rhs) noexcept {return !(Point(lhs) > rhs); }

  friend constexpr bool operator>= (const Point& lhs, const Point& rhs) noexcept {return !(lhs < rhs); }
  template <typename T> friend constexpr bool operator>= (const Point& lhs, const pair<T, T>& rhs) noexcept {return !(lhs < Point(rhs)); }
  template <typename T> friend constexpr bool operator>= (const pair<T, T>& lhs, const Point& rhs) noexcept {return !(Point(lhs) < rhs); }

  friend constexpr Point operator+ (const Point& lhs, const Point& rhs) noexcept { return Point(lhs) += rhs; }
  template <typename T> friend constexpr Point operator+ (const Point& lhs, const pair<T, T>& rhs) noexcept { return Point(lhs) += rhs; }
  template <typename T> friend constexpr Point operator+ (const pair<T, T>& lhs, const Point& rhs) noexcept { return Point(lhs) += rhs; }

  friend constexpr Point operator- (const Point& lhs, const Point& rhs) noexcept { return Point(lhs) -= rhs; }
  template <typename T> friend constexpr Point operator- (const Point& lhs, const pair<T, T>& rhs) noexcept { return Point(lhs) -= rhs; }
  template <typename T> friend constexpr Point operator- (const pair<T, T>& lhs, const Point& rhs) noexcept { return Point(lhs) -= rhs; }

  template<typename T> friend constexpr Point operator* (const Point& lhs, const T& rhs) noexcept { return Point(lhs) *= rhs; }
  template<typename T> friend constexpr Point operator* (const T& lhs, const Point& rhs) noexcept { return Point(rhs) *= lhs; }

  template<typename T> friend constexpr Point operator/ (const Point& lhs, const T& rhs) noexcept { return Point(lhs) /= rhs; }
  template<typename T> friend constexpr Point operator/ (const T& lhs, const Point& rhs) noexcept { return Point(rhs) /= lhs; }

  friend ostream& operator << (ostream& s, const Point& p) { return s << p.x << " " << p.y; }
};

constexpr Point conj (const Point& p) {return Point(p.x, -p.y); }
// The angle is in radian
template <typename T> constexpr Point rot (const Point& p, const T& angle) { return Point(cos(angle) * p.x - sin(angle) * p.y, sin(angle) * p.x + cos(angle) * p.y); }
constexpr Point rot90 (const Point& p) { return Point(-p.y, p.x); }
constexpr double cross (const Point& p, const Point& q) { return p.x * q.y - p.y * q.x; }
constexpr double dot (const Point& p, const Point& q) { return p.x * q.x + p.y * q.y; }
constexpr double norm (const Point& p) { return dot(p, p); }
constexpr double abs (const Point& p ) { return sqrt(dot(p, p)); }
constexpr double amp (const Point& p ) { double res = atan2(p.y, p.x); if (res < 0) res += M_PI * 2; return res; }
constexpr double distance (const Point& p, const Point& q) { return hypot(p.x - q.x, p.y - q.y); }

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int r, c, n;
  cin >> r >> c >> n;
  auto onBound = [&] (const Point& p) { return p.x == r || p.x == 0 || p.y == 0 || p.y == c; };
  vector<pair<Point, int>> v1, v2, v3, v4;
  for (int i = 0; i < n; i++) {
    Point p, q;
    cin >> p.x >> p.y;
    cin >> q.x >> q.y;
    if (onBound(p) && onBound(q)) {
      if (p.x == 0) v1.emplace_back(p, i);
      else if (p.y == c) v2.emplace_back(p, i);
      else if (p.x == r) v3.emplace_back(p, i);
      else if (p.y == 0) v4.emplace_back(p, i);
    }
    if (onBound(p) && onBound(q)) {
      if (q.x == 0) v1.emplace_back(q, i);
      else if (q.y == c) v2.emplace_back(q, i);
      else if (q.x == r) v3.emplace_back(q, i);
      else if (q.y == 0) v4.emplace_back(q, i);
    }
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  sort(v3.rbegin(), v3.rend());
  sort(v4.rbegin(), v4.rend());
  vector<pair<Point, int>> points;
  for (auto& i : v1) points.push_back(i);
  for (auto& i : v2) points.push_back(i);
  for (auto& i : v3) points.push_back(i);
  for (auto& i : v4) points.push_back(i);
  int m = (int) points.size();
  vector<pair<int, int>> a(n, make_pair(-1, -1));
  // for (int i = 0; i < m; i++) {
  //   cerr << points[i].first << " " << points[i].second << endl;
  // }
  vector<int> s(m + 1);
  for (int i = 0; i < m; i++) {
    if (a[points[i].second].first == -1) {
      a[points[i].second].first = i;
      s[i]++;
    } else {
      a[points[i].second].second = i;
      s[i + 1]--;
    }
  }
  for (int i = 1; i < m; i++) s[i] += s[i - 1];
  for (int i = 0; i < n; i++) if (a[i].first != -1) {
    if (s[a[i].first] != s[a[i].second]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}

Measured memory_bytes: 16288