#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct Compress {
    vector<T> xs;

    Compress(){};
    Compress(const vector<T> &vs) {add(vs);}
    Compress(const initializer_list<vector<T>> &vs) {for(auto &p : vs) add(p);}

    void add(const vector<T> &vs) {copy(begin(vs), end(vs), back_inserter(xs));}
    void add(const T &x) {xs.emplace_back(x);}

    int build() {
        sort(begin(xs), end(xs));
        xs.erase(unique(begin(xs), end(xs)), end(xs));
        return (int)xs.size();
    }

    vector<int> get(const vector<T> &vs) const {
        vector<int> ret;
        transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
            return lower_bound(begin(xs), end(xs), x) - begin(xs);
        });
        return ret;
    }

    int get(const T &x) const {return lower_bound(begin(xs), end(xs), x) - begin(xs);}

    const T &operator[](int k) const {return xs[k];}
};

template<typename T>
struct BinaryIndexedTree {
    int N;
    vector<T> data;

    BinaryIndexedTree(int N) : N(N), data(N+1,0) {}

    // [0,k) (0-indexed) a[0] + … + a[k-1]
    T sum(int k) {
        T ret = 0;
        for(; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    // [l,r) (0-indexed) a[l] + …　+ a[r-1]
    T sum(int l, int r) {
        if (l >= r) return 0;
        T vl = sum(l);
        T vr = sum(r);
        return vr - vl;
    }
    // (0-indexed) a[k] += x;
    void add(int k, T x) {
        for(++k; k <= N; k += k & -k) data[k] += x;
    }

    // (0-indexed)
    int lowerbound(T x) {
        int k = 1;
        int ret = 0;
        while ((k<<1) <= N) k <<= 1;
        while (k) {
            if (ret + k <= N && data[ret+k] < x) {
                x -= data[ret+k];
                ret += k;
            }
            k >>= 1;
        }
        return ret;
    }

    // (0-indexed)
    int upperbound(T x) {return lowerbound(x+1);}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,N; cin >> H >> W >> N;

    auto calc=[&](int x, int y) {
        if (y==0) {
            return x;
        }
        if (x==H) {
            return H+y;
        }
        if (y==W) {
            return H+W+(H-x);
        }
        if (x==0) {
            return H*2+W+(W-y);
        }
        return -1;
    };

    vector<int> L,R;
    Compress<int> Com;
    rep(i,N) {
        int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
        int l = calc(x1,y1);
        int r = calc(x2,y2);
        if (l == -1 or r == -1) continue;
        if (l > r) swap(l,r);
        L.emplace_back(l);
        R.emplace_back(r);
        Com.add(l);
        Com.add(r);
    }
    int M = Com.build();
    for (auto& i : L) i = Com.get(i);
    for (auto& i : R) i = Com.get(i);
    vector<int> idx(M/2);
    iota(all(idx),0);
    sort(all(idx),[&](int i, int j){return L[i] < L[j];});
    set<pii> dic;
    BinaryIndexedTree<int> BIT(M);
    int cur = 0;
    rep(i,M) {
        if (cur < M/2 and L[idx[cur]]==i) {
            BIT.add(i,1);
            dic.emplace(R[idx[cur]],idx[cur]);
            cur++;
        }
        auto it = dic.begin();
        if (it != dic.end() and it->first==i) {
            int num = it->second;
            if (BIT.sum(L[num]+1,i)) {
                cout << "NO" << ln;
                return 0;
            }
            BIT.add(L[num],-1);
            dic.erase(it);
        }
    }

    cout << "YES" << ln;
}

Measured memory_bytes: 5352