import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;



bool solve() {
    auto s = readln.split.map!(to!int);
    auto R = s[0];
    auto C = s[1];
    auto N = s[2];
    auto P = new Tuple!(int, int, int, int)[](N);
    bool[int] nums;
    foreach (i; 0..N) {
        s = readln.split.map!(to!int);
        P[i] = tuple(s[0], s[1], s[2], s[3]);
        nums[s[0]] = true;
        nums[s[1]] = true;
        nums[s[2]] = true;
        nums[s[3]] = true;
    }
    int[int] comp;
    auto numss = nums.keys.array;
    numss.sort();
    foreach (i, n; numss.enumerate) {
        comp[n] = i.to!int;
    }

    foreach (i; 0..N) {
        P[i][0] = comp[P[i][0]];
        P[i][1] = comp[P[i][1]];
        P[i][2] = comp[P[i][2]];
        P[i][3] = comp[P[i][3]];
    }


    bool tate(int x1, int y1, int x2, int y2) {
        return (y1 == 0 && y2 == R) || (y1 == R && y2 == 0);
    }
    bool yoko(int x1, int y1, int x2, int y2) {
        return (x1 == 0 && x2 == C) || (x1 == C && x2 == 0);
    }

    auto max_st = new MaxSegmentTree(comp.values.reduce!max + 5);
    auto min_st = new MinSegmentTree(comp.values.reduce!max + 5);
    int tate_cnt = 0;
    int yoko_cnt = 0;
    int naname_cnt = 0;

    foreach (i; 0..N) {
        auto x1 = P[i][0];
        auto y1 = P[i][1];
        auto x2 = P[i][2];
        auto y2 = P[i][3];

        if (tate(x1, y1, x2, y2) && yoko(x1, y1, x2, y2)) {
            if (tate_cnt > 0 || yoko_cnt > 0 || naname_cnt > 0) return false;
            naname_cnt += 1;
        } else if (tate(x1, y1, x2, y2)) {
            if (naname_cnt > 0 || yoko_cnt > 0) return false;
            tate_cnt += 1;
            if (y1 > y2) swap(x1, x2), swap(y1, y2);
            if (min_st.sum(x1, C) < x2 || max_st.sum(0, x1) > x2) return false;
            min_st.add(x1, x2);
            max_st.add(x1, x2);
        } else if (yoko(x1, y1, x2, y2)) {
            if (naname_cnt > 0 || tate_cnt > 0) return false;
            yoko_cnt += 1;
            if (x1 > x2) swap(x1, x2), swap(y1, y2);
            if (min_st.sum(y1, R) < y2 || max_st.sum(0, y1) > y2) return false;
            min_st.add(y1, y2);
            max_st.add(y1, y2);
        }
    }

    return true;
}

void main() {
    writeln(solve ? "YES" : "NO");
}


class MaxSegmentTree {
    int[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new int[](size);
    }

    void add(int pos, int num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, int num, int i, int left, int right) {
        if (left == right) {
            table[i] += num;
            return;
        }
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
        table[i] = max(table[i*2+1], table[i*2+2]);
    }

    int sum(int pl, int pr) {
        return sum(pl, pr, 0, 0, size/2-1);
    }

    int sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                max(sum(pl, pr, i*2+1, left, (left+right)/2),
                    sum(pl, pr, i*2+2, (left+right)/2+1, right));
    }
}


class MinSegmentTree {
    int[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new int[](size);
        fill(table, 1 << 29);
    }

    void add(int pos, int num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, int num, int i, int left, int right) {
        if (left == right) {
            table[i] += num;
            return;
        }
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
        table[i] = min(table[i*2+1], table[i*2+2]);
    }

    int sum(int pl, int pr) {
        return sum(pl, pr, 0, 0, size/2-1);
    }

    int sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 1 << 29;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                min(sum(pl, pr, i*2+1, left, (left+right)/2),
                    sum(pl, pr, i*2+2, (left+right)/2+1, right));
    }
}
