#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R, C, N;
    cin >> R >> C >> N;
    vector<plglg> bottom, right, top, left;
    REP(i, 0, N) {
        ll x[2], y[2];
        cin >> x[0] >> y[0] >> x[1] >> y[1];
        ll mark = 0;
        REP(j, 0, 2) {
            if (x[j] == 0 || x[j] == R || y[j] == 0 || y[j] == C) {
                mark++;
            }
        }
        if (mark == 2) {
            REP(j, 0, 2) {
                if (x[j] == 0 || x[j] == R) {
                    if (x[j] == 0) {
                        left.push_back(plglg(y[j], i));
                    } else {
                        right.push_back(plglg(y[j], i));
                    }
                } else {
                    if (y[j] == 0) {
                        bottom.push_back(plglg(x[j], i));
                    } else if (y[j] == C) {
                        top.push_back(plglg(x[j], i));
                    }
                }
            }
        }
    }
    sort(bottom.begin(), bottom.end());
    sort(right.begin(), right.end());
    sort(top.begin(), top.end());
    reverse(top.begin(), top.end());
    sort(left.begin(), left.end());
    reverse(left.begin(), left.end());
    deque<ll> deq;
    REP(i, 0, bottom.size()) {
        ll ind = bottom[i].second;
        if (deq.size() == 0) {
            deq.push_back(ind);
        } else {
            if (deq.back() == ind) {
                deq.pop_back();
            } else {
                deq.push_back(ind);
            }
        }
    }
    REP(i, 0, right.size()) {
        ll ind = right[i].second;
        if (deq.size() == 0) {
            deq.push_back(ind);
        } else {
            if (deq.back() == ind) {
                deq.pop_back();
            } else {
                deq.push_back(ind);
            }
        }
    }
    REP(i, 0, top.size()) {
        ll ind = top[i].second;
        if (deq.size() == 0) {
            deq.push_back(ind);
        } else {
            if (deq.back() == ind) {
                deq.pop_back();
            } else {
                deq.push_back(ind);
            }
        }
    }
    REP(i, 0, left.size()) {
        ll ind = left[i].second;
        if (deq.size() == 0) {
            deq.push_back(ind);
        } else {
            if (deq.back() == ind) {
                deq.pop_back();
            } else {
                deq.push_back(ind);
            }
        }
    }
    while(deq.size() != 0 && deq.front() == deq.back()) {
        deq.pop_back();
        deq.pop_front();
    }
    if (deq.size() == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 4944