#include <cstdio>
#include <stack>
#include <vector>
#include <algorithm>

const int N = 100000 + 10;

int x, y, n;

int pos(int a, int b) {
  if (b == 0) return a;
  if (a == x) return b + x;
  if (b == y) return 2 * x + y - a;
  if (a == 0) return 2 * x + 2 * y - b;
  return -1;
}

int main() {
  scanf("%d%d%d", &x, &y, &n);
  std::vector<std::pair<int, int>> pool;
  for (int i = 1; i <= n; ++i) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int a = pos(x1, y1), b = pos(x2, y2);
    if (a == -1 || b == -1) continue;
    if (a > b) std::swap(a, b);
    pool.emplace_back(a, b);
  }
  std::sort(pool.begin(), pool.end());
  std::stack<int> stk;
  for (auto it : pool) {
    while (!stk.empty() && stk.top() < it.first) stk.pop();
    if (!stk.empty() && it.second > stk.top()) return puts("NO"), 0;
    stk.push(it.second);
  }
  puts("YES");
  return 0;
}
